Class IndexedAsyncEnumerator<T>
- Namespace
- Garyon.Objects.Enumerators
- Assembly
- Garyon.dll
An enumerator that enumerates elements of an IEnumerable<T> while also preserving the enumeration index.
public class IndexedAsyncEnumerator<T> : IAsyncEnumerator<IndexedEnumeratorResult<T>>, IAsyncDisposable
Type Parameters
TThe type of elements that are being enumerated.
- Inheritance
-
IndexedAsyncEnumerator<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
IndexedAsyncEnumerator(IAsyncEnumerable<T>)
Initializes a new instance of the IndexedAsyncEnumerator<T> class from an IAsyncEnumerable<T>, using its GetAsyncEnumerator(CancellationToken) function.
public IndexedAsyncEnumerator(IAsyncEnumerable<T> originalEnumerable)
Parameters
originalEnumerableIAsyncEnumerable<T>The original IAsyncEnumerable<T> whose IAsyncEnumerator<T> to wrap with this IndexedAsyncEnumerator<T>.
IndexedAsyncEnumerator(IAsyncEnumerator<T>)
Initializes a new instance of the IndexedAsyncEnumerator<T> class from an IAsyncEnumerator<T>.
public IndexedAsyncEnumerator(IAsyncEnumerator<T> originalEnumerator)
Parameters
originalEnumeratorIAsyncEnumerator<T>The original IAsyncEnumerator<T> to wrap with this IndexedAsyncEnumerator<T>.
Properties
Current
Gets the current IndexedEnumeratorResult<T> in the enumerator.
public IndexedEnumeratorResult<T> Current { get; }
Property Value
Index
The current index in the enumerator.
public int Index { get; }
Property Value
Methods
DisposeAsync()
Disposes the async enumerator by calling its DisposeAsync() implementation.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
MoveNextAsync()
Advances the enumerator asynchronously to the next element of the collection.
public ValueTask<bool> MoveNextAsync()
Returns
- ValueTask<bool>
A ValueTask<TResult> that will complete with a result of
trueif the enumerator was successfully advanced to the next element, orfalseif the enumerator has passed the end of the collection.