Sequence
Various methods to work with classes implementing IEnumerable<T> interface.
Gets enumerable collection created from generator method.
Represents a wrapped for method TryTake
in the form of enumerable collection.
Gets enumerable collection created from generator method.
Wrapped for the enumerator which is limited by count.
Adds items to the end of collection.
Obtains element at the specified index in the sequence.
public static ValueTask<Optional<T>> ElementAtAsync<T>(this IAsyncEnumerable<T> collection, int index, CancellationToken token = default)
Obtains element at the specified index in the sequence.
Obtains first value in the sequence; or None
if sequence is empty.
Returns the first element in a sequence that satisfies a specified condition.
public static ValueTask<Optional<T>> FirstOrEmptyAsync<T>(this IAsyncEnumerable<T> seq, CancellationToken token = default)
Obtains first value in the sequence; or None
if sequence is empty.
public static ValueTask<Optional<T>> FirstOrEmptyAsync<T>(this IAsyncEnumerable<T> seq, Predicate<T> filter, CancellationToken token = default)
Returns the first element in a sequence that satisfies a specified condition.
Obtains first value type in the sequence; or null
if sequence is empty.
public static ValueTask<T?> FirstOrNullAsync<T>(this IAsyncEnumerable<T> seq, CancellationToken token = default) where T : struct
Obtains first value type in the sequence; or null
if sequence is empty.
Applies specified action to each collection element.
public static ValueTask ForEachAsync<T>(this IAsyncEnumerable<T> collection, Action<T> action, CancellationToken token = default)
Applies specified action to each collection element asynchronously.
public static ValueTask ForEachAsync<T>(this IAsyncEnumerable<T> collection, Func<T, CancellationToken, ValueTask> action, CancellationToken token = default)
Applies specified action to each collection element asynchronously.
public static ValueTask ForEachAsync<T>(this IEnumerable<T> collection, Func<T, CancellationToken, ValueTask> action, CancellationToken token = default)
Applies the specified asynchronous action to each collection element.
public static IAsyncEnumerator<T> GetAsyncEnumerator<T>(this IEnumerable<T> enumerable, CancellationToken token = default)
Obtains asynchronous enumerator over the sequence of elements.
Gets consumer of thread-safe concurrent collection.
public static LimitedEnumerator<T> Limit<T>(this IEnumerator<T> enumerator, int count, bool leaveOpen = false)
Limits the number of the elements in the sequence.
Adds items to the beginning of collection.
Computes hash code for the sequence of objects.
Constructs a sequence from the single element.
Bypasses a specified number of elements in a sequence.
public static bool Skip<TEnumerator, T>(this ref TEnumerator enumerator, int count) where TEnumerator : struct, IEnumerator<T>
Bypasses a specified number of elements in a sequence.
Bypasses a specified number of elements in a sequence.
Skip null values in the collection.
Skip null values in the collection.
public static Task<T[]> ToArrayAsync<T>(this IAsyncEnumerable<T> collection, int initialCapacity = 10, MemoryAllocator<T> allocator = null, CancellationToken token = default)
Converts asynchronous collection to the array.
Converts synchronous collection of elements to asynchronous.
public static AsyncGenerator<T> ToAsyncEnumerable<T>(this Func<CancellationToken, ValueTask<Optional<T>>> generator)
Converts generator function to enumerable collection.
Converts generator function to enumerable collection.
Gets enumerator over all elements in the memory.
public static string ToString<T>(this IEnumerable<T> collection, string delimiter, string ifEmpty = "")
Concatenates each element from the collection into single string.