Class IndexedEnumerator<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 IndexedEnumerator<T> : IEnumerator<IndexedEnumeratorResult<T>>, IEnumerator, IDisposable
Type Parameters
TThe type of elements that are being enumerated.
- Inheritance
-
IndexedEnumerator<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
IndexedEnumerator(IEnumerable<T>)
Initializes a new instance of the IndexedEnumerator<T> class from an IEnumerable<T>, using its GetEnumerator() function.
public IndexedEnumerator(IEnumerable<T> originalEnumerable)
Parameters
originalEnumerableIEnumerable<T>The original IEnumerable<T> whose IEnumerator<T> to wrap with this IndexedEnumerator<T>.
IndexedEnumerator(IEnumerator<T>)
Initializes a new instance of the IndexedEnumerator<T> class from an IEnumerator<T>.
public IndexedEnumerator(IEnumerator<T> originalEnumerator)
Parameters
originalEnumeratorIEnumerator<T>The original IEnumerator<T> to wrap with this IndexedEnumerator<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
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
MoveNext()
Advances the enumerator to the next element of the collection.
public bool MoveNext()
Returns
- bool
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
Exceptions
- InvalidOperationException
The collection was modified after the enumerator was created.
Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.
public void Reset()
Exceptions
- InvalidOperationException
The collection was modified after the enumerator was created.
- NotSupportedException
The enumerator does not support being reset.