Collection
Provides utility methods to work with collections.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace DotNext.Collections.Generic
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public static class Collection
{
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1
})]
public static ReadOnlyCollectionView<TInput, TOutput> Convert<[System.Runtime.CompilerServices.Nullable(2)] TInput, [System.Runtime.CompilerServices.Nullable(2)] TOutput>(this IReadOnlyCollection<TInput> collection, Converter<TInput, TOutput> converter)
{
return new ReadOnlyCollectionView<TInput, TOutput>(collection, converter);
}
private static T[] ToArray<TCollection, [System.Runtime.CompilerServices.Nullable(2)] T>(TCollection collection, int count) where TCollection : class, IEnumerable<T>
{
T[] array = new T[count];
long num = 0;
foreach (T item in (IEnumerable<T>)collection) {
T[] array2 = array;
long num2 = num;
num = num2 + 1;
array2[num2] = item;
}
return array;
}
public static T[] ToArray<[System.Runtime.CompilerServices.Nullable(2)] T>(ICollection<T> collection)
{
return ToArray<ICollection<T>, T>(collection, collection.Count);
}
public static T[] ToArray<[System.Runtime.CompilerServices.Nullable(2)] T>(IReadOnlyCollection<T> collection)
{
return ToArray<IReadOnlyCollection<T>, T>(collection, collection.Count);
}
public static void AddAll<[System.Runtime.CompilerServices.Nullable(2)] T>(this ICollection<T> collection, IEnumerable<T> items)
{
items.ForEach(collection.Add);
}
}
}