Struct UnsafeBitArray
An arbitrarily-sized array of bits.
Implements
Namespace: Unity.Collections.LowLevel.Unsafe
Assembly: solution.dll
Syntax
public struct UnsafeBitArray : INativeDisposable
Remarks
The number of allocated bytes is always a multiple of 8. For example, a 65-bit array could fit in 9 bytes, but its allocation is actually 16 bytes.
Constructors
Name | Description |
---|---|
UnsafeBitArray(int, AllocatorHandle, NativeArrayOptions) | Initializes and returns an instance of UnsafeBitArray. |
UnsafeBitArray(void*, int, AllocatorHandle) | Initializes and returns an instance of UnsafeBitArray which aliases an existing buffer. |
Fields
Name | Description |
---|---|
Allocator | The allocator to use. |
Capacity | The capacity number of bits. |
Length | The number of bits. |
Ptr | Pointer to the data. |
Properties
Name | Description |
---|---|
IsCreated | Whether this array has been allocated (and not yet deallocated). |
IsEmpty | Whether the container is empty. |
Methods
Name | Description |
---|---|
AsReadOnly() | Returns a readonly version of this UnsafeBitArray instance. |
Clear() | Sets all the bits to 0. |
Copy(int, int, int) | Copies a range of bits from this array to another range in this array. |
Copy(int, ref UnsafeBitArray, int, int) | Copies a range of bits from an array to a range of bits in this array. |
CountBits(int, int) | Returns the number of bits in a range that are 1. |
Dispose() | Releases all resources (memory and safety handles). |
Dispose(JobHandle) | Creates and schedules a job that will dispose this array. |
Find(int, int) | Returns the index of the first occurrence in this array of N contiguous 0 bits. |
Find(int, int, int) | Returns the index of the first occurrence in this array of a given number of contiguous 0 bits. |
GetBits(int, int) | Returns a ulong which has bits copied from this array. |
IsSet(int) | Returns true if the bit at an index is 1. |
Resize(int, NativeArrayOptions) | Sets the length, expanding the capacity if necessary. |
Set(int, bool) | Sets the bit at an index to 0 or 1. |
Set(ulong*, int, bool) | Sets the bit at an index to 0 or 1. |
SetBits(int, bool, int) | Sets a range of bits to 0 or 1. |
SetBits(int, ulong, int) | Copies bits of a ulong to bits in this array. |
SetCapacity(int) | Sets the capacity. |
TrimExcess() | Sets the capacity to match what it would be if it had been originally initialized with all its entries. |