Collection
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace DotNext.Collections.Generic
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public static class Collection
{
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1
})]
public static ReadOnlyCollectionView<TInput, TOutput> Convert<TInput, TOutput>([System.Runtime.CompilerServices.Nullable(1)] this IReadOnlyCollection<TInput> collection, [In] [IsReadOnly] [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
1
})] ref ValueFunc<TInput, TOutput> converter)
{
return new ReadOnlyCollectionView<TInput, TOutput>(collection, ref converter);
}
[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)
{
ValueFunc<TInput, TOutput> converter2 = converter.AsValueFunc(true);
return collection.Convert(ref converter2);
}
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);
}
}
}