Show / Hide Table of Contents

Class Enumerator

Various methods to work with classes implementing IEnumerable<T> interface.

Inheritance
object
Enumerator
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public static class Enumerator

Methods

| Edit this page View Source

GetAsyncEnumerator<T>(IEnumerable<T>, CancellationToken)

Returns the 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 caller can use 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

enumerable is null.

| Edit this page View Source

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

false to dispose enumerator; otherwise, true.

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.

| Edit this page View Source

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

true, if current element is available; otherwise, false.

Type Parameters
Name Description
T

The type of the elements in the sequence.

| Edit this page View Source

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

true, if current element is available; otherwise, false.

Type Parameters
Name Description
TEnumerator

The type of the sequence.

T

The type of the elements in the sequence.

| Edit this page View Source

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.

| Edit this page View Source

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.

See Also
ToEnumerable<T>(ReadOnlyMemory<T>)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾