Struct ScyllaBitArrayDOTS.Enumerator
Allocation-free, Burst-compatible value-type enumerator that yields the zero-based indices of all set bits in ascending order.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public struct ScyllaBitArrayDOTS.Enumerator
Remarks
The enumerator uses the bit-manipulation trick of isolating and clearing the lowest
set bit of each word (word & (word - 1)) combined with
math.tzcnt to determine the bit position in O(1) per set bit, skipping runs
of zero words cheaply. The enumerator holds a read-only reference to the
Unity.Collections.NativeArray<T> of the parent ScyllaBitArrayDOTS and
does not support modification during enumeration.
Constructors
Enumerator(ScyllaBitArrayDOTS)
Initializes a new ScyllaBitArrayDOTS.Enumerator for the specified ScyllaBitArrayDOTS.
Declaration
public Enumerator(ScyllaBitArrayDOTS bitArray)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArrayDOTS | bitArray | The DOTS bit array to enumerate. Should have IsCreated
equal to |
Properties
Current
Gets the zero-based index of the set bit at the current enumerator position.
Declaration
public int Current { get; }
Property Value
| Type | Description |
|---|---|
| int | The current set-bit index. Undefined if MoveNext() has not yet
been called or returned |
Methods
MoveNext()
Advances the enumerator to the next set bit.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Internally clears the lowest set bit of the current working word after each yield and advances to the next non-zero word when the current word is exhausted. This makes the iteration cost proportional to the number of set bits rather than the total capacity.