Class Enumerator
Various methods to work with classes implementing IEnumerable<T> interface.
Inherited Members
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public static class Enumerator
Methods
| Edit this page View SourceGetAsyncEnumerator<T>(IEnumerable<T>, CancellationToken)
Obtains asynchronous enumerator over the sequence of elements.
Declaration
public static IAsyncEnumerator<T> GetAsyncEnumerator<T>(this IEnumerable<T> enumerable, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The collection of elements. |
CancellationToken | token | The token that can be used by consumer to cancel the enumeration. |
Returns
Type | Description |
---|---|
IAsyncEnumerator<T> | The asynchronous wrapper over synchronous enumerator. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the collection. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Limit<T>(IEnumerator<T>, int, bool)
Limits the number of the elements in the sequence.
Declaration
public static Enumerator.LimitedEnumerator<T> Limit<T>(this IEnumerator<T> enumerator, int count, bool leaveOpen = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerator<T> | enumerator | The sequence of the elements. |
int | count | The maximum number of the elements in the returned sequence. |
bool | leaveOpen |
Returns
Type | Description |
---|---|
Enumerator.LimitedEnumerator<T> | The enumerator which is limited by count. |
Type Parameters
Name | Description |
---|---|
T | The type of items in the sequence. |
Skip<T>(IEnumerator<T>, int)
Bypasses a specified number of elements in a sequence.
Declaration
public static bool Skip<T>(this IEnumerator<T> enumerator, int count)
Parameters
Type | Name | Description |
---|---|---|
IEnumerator<T> | enumerator | Enumerator to modify. Cannot be null. |
int | count | The number of elements to skip. |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in the sequence. |
Skip<TEnumerator, T>(ref TEnumerator, int)
Bypasses a specified number of elements in a sequence.
Declaration
public static bool Skip<TEnumerator, T>(this ref TEnumerator enumerator, int count) where TEnumerator : struct, IEnumerator<T>
Parameters
Type | Name | Description |
---|---|---|
TEnumerator | enumerator | Enumerator to modify. |
int | count | The number of elements to skip. |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
TEnumerator | The type of the sequence. |
T | The type of the elements in the sequence. |
ToEnumerator<T>(in ReadOnlySequence<T>)
Gets enumerator over all elements in the sequence.
Declaration
public static IEnumerator<T> ToEnumerator<T>(in ReadOnlySequence<T> sequence)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySequence<T> | sequence | A sequence of elements. |
Returns
Type | Description |
---|---|
IEnumerator<T> | The enumerator over all elements in the sequence. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the sequence. |
ToEnumerator<T>(ReadOnlyMemory<T>)
Gets enumerator over all elements in the memory.
Declaration
public static IEnumerator<T> ToEnumerator<T>(ReadOnlyMemory<T> memory)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlyMemory<T> | memory | The memory block to be converted. |
Returns
Type | Description |
---|---|
IEnumerator<T> | The enumerator over all elements in the memory. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the memory. |