Struct BitField64
Fixed size 64-bit array of bits.
Namespace: Unity.Collections
Syntax
public struct BitField64
Constructors
BitField64(UInt64)
Constructor.
Declaration
public BitField64(ulong initialValue = 0UL)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | initialValue | Initial value of bit field. Default is 0. |
Fields
Value
64-bit data storage.
Declaration
public ulong Value
Field Value
Type | Description |
---|---|
UInt64 |
Methods
Clear()
Clear all bits to 0.
Declaration
public void Clear()
CountBits()
Calculate number of set bits.
Declaration
public int CountBits()
Returns
Type | Description |
---|---|
Int32 | Number of set bits. |
CountLeadingZeros()
Calculate number of leading zeros.
Declaration
public int CountLeadingZeros()
Returns
Type | Description |
---|---|
Int32 | Number of leading zeros |
CountTrailingZeros()
Calculate number of trailing zeros.
Declaration
public int CountTrailingZeros()
Returns
Type | Description |
---|---|
Int32 | Number of trailing zeros |
GetBits(Int32, Int32)
Returns all bits in range as uint.
Declaration
public ulong GetBits(int pos, int numBits = 1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-63). |
Int32 | numBits | Number of bits to set (must be 1-64). |
Returns
Type | Description |
---|---|
UInt64 | Returns requested range of bits. |
IsSet(Int32)
Returns true is bit at position is set.
Declaration
public bool IsSet(int pos)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-31). |
Returns
Type | Description |
---|---|
Boolean | Returns true if bit is set. |
SetBits(Int32, Boolean, Int32)
Set bits to desired boolean value.
Declaration
public void SetBits(int pos, bool value, int numBits = 1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-63). |
Boolean | value | Value of bits to set. |
Int32 | numBits | Number of bits to set (must be 1-64). |
TestAll(Int32, Int32)
Returns true if all of bits in range are set.
Declaration
public bool TestAll(int pos, int numBits = 1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-63). |
Int32 | numBits | Number of bits to set (must be 1-64). |
Returns
Type | Description |
---|---|
Boolean | Returns true if all bits are set. |
TestAny(Int32, Int32)
Returns true if any of bits in range are set.
Declaration
public bool TestAny(int pos, int numBits = 1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-63). |
Int32 | numBits | Number of bits to set (must be 1-64). |
Returns
Type | Description |
---|---|
Boolean | Returns true if at least one bit is set. |
TestNone(Int32, Int32)
Returns true if none of bits in range are set.
Declaration
public bool TestNone(int pos, int numBits = 1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | pos | Position in bitfield (must be 0-63). |
Int32 | numBits | Number of bits to set (must be 1-64). |
Returns
Type | Description |
---|---|
Boolean | Returns true if none of bits are set. |