Struct ScyllaBitArray.Enumerator
Allocation-free 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 ScyllaBitArray.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 does not support modification of the
underlying array during enumeration.
Constructors
Enumerator(ScyllaBitArray)
Initializes a new ScyllaBitArray.Enumerator for the specified ScyllaBitArray.
Declaration
public Enumerator(ScyllaBitArray bitArray)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaBitArray | bitArray | The bit array to enumerate. Must not be |
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 Scylla.Core.Structures.ScyllaBitArray.Enumerator._currentWord after each yield and advances to the next non-zero word when the current word is exhausted. This makes the cost proportional to the number of set bits rather than the total capacity.