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
View SourceCreate<T, TEnumerator>(in TEnumerator)
Creates the classic enumerator.
Declaration
public static IEnumerator<T> Create<T, TEnumerator>(in TEnumerator enumerator) where T : allows ref struct where TEnumerator : struct, IEnumerator<TEnumerator, T>
Parameters
| Type | Name | Description |
|---|---|---|
| TEnumerator | enumerator | The enumerator to convert. |
Returns
| Type | Description |
|---|---|
| IEnumerator<T> | The classic enumerator. |
Type Parameters
| Name | Description |
|---|---|
| T | |
| TEnumerator | The type of the enumerator. |
Create<T, TEnumerator>(in TEnumerator, CancellationToken)
Creates the async enumerator.
Declaration
public static IAsyncEnumerator<T> Create<T, TEnumerator>(in TEnumerator enumerator, CancellationToken token) where T : allows ref struct where TEnumerator : struct, IEnumerator<TEnumerator, T>
Parameters
| Type | Name | Description |
|---|---|---|
| TEnumerator | enumerator | The enumerator to convert. |
| CancellationToken | token | The token that can be used to cancel the enumeration. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerator<T> | The async enumerator. |
Type Parameters
| Name | Description |
|---|---|
| T | |
| TEnumerator | The type of the enumerator. |
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) where T : allows ref struct
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<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>, allows ref struct where T : allows ref struct
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. |
op_LeftShift<T>(IAsyncEnumerator<T>, int)
Bypasses a specified number of elements in a sequence.
Declaration
public static ValueTask<bool> op_LeftShift<T>(IAsyncEnumerator<T> enumerator, int count) where T : allows ref struct
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerator<T> | enumerator | Enumerator to modify. Cannot be null. |
| int | count | The number of elements to skip. |
Returns
| Type | Description |
|---|---|
| ValueTask<bool> |
Type Parameters
| Name | Description |
|---|---|
| T |
Exceptions
| Type | Condition |
|---|---|
| OperationCanceledException | The operation has been canceled. |
op_LeftShift<T>(IEnumerator<T>, int)
Bypasses a specified number of elements in a sequence.
Declaration
public static bool op_LeftShift<T>(IEnumerator<T> enumerator, int count) where T : allows ref struct
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 |