Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

UnsafeBitArray

struct in Unity.Collections.LowLevel.Unsafe


Implements interfaces:INativeDisposable

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

An arbitrarily-sized array of bits.

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.

Static Properties

Property Description
MaxCapacity The maximum number of elements this type of container can hold.

Properties

Property Description
Allocator The allocator to use.
Capacity The capacity number of bits.
IsCreated Whether this array has been allocated (and not yet deallocated).
IsEmpty Whether the container is empty.
Length The number of bits.
Ptr Pointer to the data.

Constructors

Constructor Description
UnsafeBitArray Initializes and returns an instance of UnsafeBitArray which aliases an existing buffer.

Public Methods

Method Description
AsReadOnly Returns a readonly version of this UnsafeBitArray instance.
Clear Sets all the bits to 0.
Copy Copies a range of bits from this array to another range in this array.
CountBits Returns the number of bits in a range that are 1.
Dispose Releases all resources (memory and safety handles).
Find Find a sequence of N contiguous 0 bits in a bit array. To achieve higher performance, it is not guaranteed that the found index is necessarily the first occurrence of such a sequence.
GetBits Returns a ulong which has bits copied from this array.
IsSet Returns true if the bit at an index is 1.
Resize Sets the length, expanding the capacity if necessary.
SetBits Sets a range of bits to 0 or 1.
SetCapacity Sets the capacity.
TestAll Returns true if all of the bits in a range are 1.
TestAny Returns true if at least one of the bits in a range is 1.
TestNone Returns true if none of the bits in a range are 1 ("i.e." all bits in the range are 0).
TrimExcess Sets the capacity to match what it would be if it had been originally initialized with all its entries.

Static Methods

Method Description
Set Sets the bit at an index to 0 or 1.