Struct ScyllaRingBuffer<T>.Enumerator
Value-type forward enumerator for ScyllaRingBuffer<T> that enables allocation-free iteration in oldest-to-newest (FIFO) order.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public struct ScyllaRingBuffer<T>.Enumerator
Remarks
The enumerator captures a snapshot of _count and _head at construction time.
Modifications to the ring buffer during enumeration are not detected and may produce
unpredictable results. For safe concurrent iteration, use a synchronized wrapper and hold the lock
for the duration of the enumeration.
Constructors
Enumerator(ScyllaRingBuffer<T>)
Initializes a new forward enumerator for the specified ring buffer, capturing a snapshot of the buffer's current head and count.
Declaration
public Enumerator(ScyllaRingBuffer<T> ringBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaRingBuffer<T> | ringBuffer | The ring buffer to enumerate. Must not be |
Properties
Current
Gets the element at the current enumerator position.
Declaration
public readonly T Current { get; }
Property Value
| Type | Description |
|---|---|
| T | The element at the current logical step. Undefined before the first call to
MoveNext() and after MoveNext() returns |
Methods
MoveNext()
Advances the enumerator to the next element in oldest-to-newest order and updates Current.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The physical index is computed as (_start + _index) % Capacity, implemented with a
subtract-instead-of-modulo to avoid a division. The enumerator iterates up to
_countSnapshot elements, even if elements were added or removed after construction.