DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="5.2.0" />

 Collection

public static class Collection
Provides utility methods to work with collections.

Represents a wrapped for method TryTake in the form of enumerable collection.

public static void AddAll<T>(this ICollection<T> collection, IEnumerable<T> items)

Adds multiple items into collection.

public static IEnumerable<T> Append<T>(this IEnumerable<T> collection, T[] items)

Adds items to the end of collection.

public static ReadOnlyCollectionView<TInput, TOutput> Convert<TInput, TOutput>(this IReadOnlyCollection<TInput> collection, Converter<TInput, TOutput> converter)

Returns lazily converted read-only collection.

public static MemoryOwner<T> Copy<T>(this IEnumerable<T> enumerable, int sizeHint = 0, MemoryAllocator<T> allocator = null)

Creates a copy of the elements from the collection.

public static bool ElementAt<T>(this IEnumerable<T> collection, int index, out T element)

Obtains element at the specified index in the sequence.

public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)

Applies specified action to each collection element.

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 ConsumingEnumerable<T> GetConsumer<T>(this IProducerConsumerCollection<T> collection)

Gets consumer of thread-safe concurrent collection.

public static IEnumerable<T> Prepend<T>(this IEnumerable<T> collection, T[] items)

Adds items to the beginning of collection.

public static int SequenceHashCode<T>(this IEnumerable<T> sequence, bool salted = true)

Computes hash code for the sequence of objects.

public static IEnumerable<T> SkipNulls<T>(this IEnumerable<T> collection)

Skip null values in the collection.

public static T[] ToArray<T>(ICollection<T> collection)

Converts collection into single-dimensional array.

public static T[] ToArray<T>(IReadOnlyCollection<T> collection)

Converts read-only collection into single-dimensional array.

public static IAsyncEnumerable<T> ToAsyncEnumerable<T>(this IEnumerable<T> enumerable)

Converts synchronous collection of elements to asynchronous.

public static string ToString<T>(this IEnumerable<T> collection, string delimiter, string ifEmpty = "")

Concatenates each element from the collection into single string.