Struct ScyllaQueue<T>.Enumerator
Value-type enumerator for ScyllaQueue<T> that supports allocation-free
foreach iteration when used directly on the concrete queue type.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public struct ScyllaQueue<T>.Enumerator
Remarks
This struct enumerator satisfies the duck-typed foreach pattern (providing GetEnumerator(), MoveNext(), and Current) without implementing IEnumerable<T>, which would require a heap allocation for the enumerator object. Using it through the interface would box the struct; use it exclusively on the concrete type for zero-allocation enumeration.
The enumerator takes a snapshot of _head and _count at construction
time. It does not detect concurrent modifications.
Constructors
Enumerator(ScyllaQueue<T>)
Initializes a new ScyllaQueue<T>.Enumerator positioned before the first element of the specified queue.
Declaration
public Enumerator(ScyllaQueue<T> queue)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaQueue<T> | queue | The queue to enumerate. The enumerator snapshots the queue's head and count at this moment; subsequent modifications to the queue are not reflected. |
Properties
Current
Gets the element at the current position of the enumerator.
Declaration
public readonly T Current { get; }
Property Value
| Type | Description |
|---|---|
| T | The element in the queue at the current iteration position. Undefined (returns
|
Methods
MoveNext()
Advances the enumerator to the next element in FIFO order.
Declaration
public bool MoveNext()
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
The physical buffer index is computed as (_start + _index) % bufferLength
using a branch-free subtract instead of a modulo operation for performance.