Struct ScyllaRingBuffer<T>.ReverseEnumerator
Value-type reverse enumerator for ScyllaRingBuffer<T> that enables allocation-free iteration in newest-to-oldest order.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public struct ScyllaRingBuffer<T>.ReverseEnumerator
Remarks
The enumerator captures snapshots of _count and _tail at construction time to
determine the starting physical position and iteration bound. The newest element's physical index
is computed as _tail - 1 with wraparound. Subsequent elements are obtained by subtracting
one from the physical index (with wraparound) at each step.
Modifications to the ring buffer during enumeration are not detected and may produce unpredictable results.
Constructors
ReverseEnumerator(ScyllaRingBuffer<T>)
Initializes a new reverse enumerator for the specified ring buffer, capturing a snapshot of the buffer's current tail and count.
Declaration
public ReverseEnumerator(ScyllaRingBuffer<T> ringBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaRingBuffer<T> | ringBuffer | The ring buffer to enumerate in reverse. 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 reverse-order step. Undefined before the first call to
MoveNext() and after MoveNext() returns |
Methods
MoveNext()
Advances the enumerator to the next element in newest-to-oldest order and updates Current.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The physical index is computed as _newestPhysical - _index, with wraparound applied
when the result is negative (i.e., when iterating past the start of the backing array).