static TResult[] ToArray <TEnumerable, TEnumerator, TSource, TResult>(this TEnumerable source, NullableSelectorAt <TSource, TResult> selector)
            where TEnumerable : notnull, IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
            var array = new TResult[source.Count];

            ValueReadOnlyCollectionExtensions.Copy <TEnumerable, TEnumerator, TSource, TResult>(source, array, selector);
            return(array);
        }
        static IMemoryOwner <TResult> ToArray <TEnumerable, TEnumerator, TSource, TResult>(this TEnumerable source, NullableSelectorAt <TSource, TResult> selector, MemoryPool <TResult> pool)
            where TEnumerable : notnull, IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
            Debug.Assert(pool is object);

            var result = pool.RentSliced(source.Count);

            ValueReadOnlyCollectionExtensions.Copy <TEnumerable, TEnumerator, TSource, TResult>(source, result.Memory.Span, selector);
            return(result);
        }
        public static TSource[] ToArray <TEnumerable, TEnumerator, TSource>(this TEnumerable source)
            where TEnumerable : notnull, IValueReadOnlyCollection <TSource, TEnumerator>
            where TEnumerator : struct, IEnumerator <TSource>
        {
#if NET5_0
            var result = GC.AllocateUninitializedArray <TSource>(source.Count);
#else
            var result = new TSource[source.Count];
#endif
            ValueReadOnlyCollectionExtensions.Copy <TEnumerable, TEnumerator, TSource>(source, result);
            return(result);
        }
 public static ValueReadOnlyCollectionExtensions.SelectAtEnumerable <ValueWrapper <TSource>, ImmutableHashSet <TSource> .Enumerator, TSource, TResult, FunctionWrapper <TSource, int, TResult> > Select <TSource, TResult>(
     this ImmutableHashSet <TSource> source,
     Func <TSource, int, TResult> selector)
 => ValueReadOnlyCollectionExtensions.Select <ValueWrapper <TSource>, ImmutableHashSet <TSource> .Enumerator, TSource, TResult>(new ValueWrapper <TSource>(source), selector);
Exemplo n.º 5
0
 public static ValueReadOnlyCollectionExtensions.SkipTakeEnumerable <ValueWrapper <TSource>, Queue <TSource> .Enumerator, TSource> Take <TSource>(this Queue <TSource> source, int count)
 => ValueReadOnlyCollectionExtensions.Take <ValueWrapper <TSource>, Queue <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), count);
 public static Option <KeyValuePair <TKey, TValue> > First <TKey, TValue>(this Dictionary <TKey, TValue> source)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.First <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source));
 public static ValueReadOnlyCollectionExtensions.SelectAtEnumerable <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue>, TResult> Select <TKey, TValue, TResult>(
     this Dictionary <TKey, TValue> source,
     NullableSelectorAt <KeyValuePair <TKey, TValue>, TResult> selector)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.Select <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue>, TResult>(new ValueWrapper <TKey, TValue>(source), selector);
 public static bool Any <TKey, TValue>(this Dictionary <TKey, TValue> source, PredicateAt <KeyValuePair <TKey, TValue> > predicate)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.Any <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source), predicate);
 public static Dictionary <TKey2, TElement> ToDictionary <TKey, TValue, TKey2, TElement>(this Dictionary <TKey, TValue> source, Selector <KeyValuePair <TKey, TValue>, TKey2> keySelector, NullableSelector <KeyValuePair <TKey, TValue>, TElement> elementSelector, IEqualityComparer <TKey2>?comparer = default)
     where TKey : notnull
     where TKey2 : notnull
 => ValueReadOnlyCollectionExtensions.ToDictionary <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue>, TKey2, TElement>(new ValueWrapper <TKey, TValue>(source), keySelector, elementSelector, comparer);
 public static Option <TKey> Single <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source)
 => ValueReadOnlyCollectionExtensions.Single <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source));
Exemplo n.º 11
0
 public static Dictionary <TKey2, TKey> ToDictionary <TKey, TValue, TKey2>(this Dictionary <TKey, TValue> .KeyCollection source, NullableSelector <TKey, TKey2> keySelector, IEqualityComparer <TKey2>?comparer = default)
 => ValueReadOnlyCollectionExtensions.ToDictionary <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .KeyCollection.Enumerator, TKey, TKey2>(new ValueWrapper <TKey, TValue>(source), keySelector, comparer);
Exemplo n.º 12
0
 public static bool All <TSource>(this HashSet <TSource> source, Predicate <TSource> predicate)
 => ValueReadOnlyCollectionExtensions.All <ValueWrapper <TSource>, HashSet <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), predicate);
 public static ValueReadOnlyCollectionExtensions.SkipTakeEnumerable <ValueWrapper <TSource>, SortedSet <TSource> .Enumerator, TSource> Skip <TSource>(this SortedSet <TSource> source, int count)
 => ValueReadOnlyCollectionExtensions.Skip <ValueWrapper <TSource>, SortedSet <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), count);
 public static ValueReadOnlyCollectionExtensions.SelectAtEnumerable <ValueWrapper <TSource>, ImmutableHashSet <TSource> .Enumerator, TSource, TResult, TSelector> SelectAt <TSource, TResult, TSelector>(
     this ImmutableHashSet <TSource> source,
     TSelector selector = default)
     where TSelector : struct, IFunction <TSource, int, TResult>
 => ValueReadOnlyCollectionExtensions.SelectAt <ValueWrapper <TSource>, ImmutableHashSet <TSource> .Enumerator, TSource, TResult, TSelector>(new ValueWrapper <TSource>(source), selector);
 public static ValueReadOnlyCollectionExtensions.SelectAtEnumerable <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey, TResult> Select <TKey, TValue, TResult>(
     this SortedDictionary <TKey, TValue> .KeyCollection source,
     NullableSelectorAt <TKey, TResult> selector)
 => ValueReadOnlyCollectionExtensions.Select <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey, TResult>(new ValueWrapper <TKey, TValue>(source), selector);
Exemplo n.º 16
0
 public static Option <TKey> First <TKey, TValue>(this Dictionary <TKey, TValue> .KeyCollection source)
 => ValueReadOnlyCollectionExtensions.First <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source));
 public static Option <TKey> ElementAt <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source, int index)
 => ValueReadOnlyCollectionExtensions.ElementAt <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source), index);
 public static TKey[] ToArray <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source)
 => ValueReadOnlyCollectionExtensions.ToArray <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source));
 public static Dictionary <TKey, TValue> ToDictionary <TKey, TValue>(this Dictionary <TKey, TValue> source, IEqualityComparer <TKey>?comparer = default)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.ToDictionary <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue>, TKey, TValue>(new ValueWrapper <TKey, TValue>(source), item => item.Key, item => item.Value, comparer);
 public static Dictionary <TKey2, TKey> ToDictionary <TKey, TValue, TKey2>(this SortedDictionary <TKey, TValue> .KeyCollection source, NullableSelector <TKey, TKey2> keySelector)
 => ValueReadOnlyCollectionExtensions.ToDictionary <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey, TKey2>(new ValueWrapper <TKey, TValue>(source), keySelector);
 public static ValueReadOnlyCollectionExtensions.SkipTakeEnumerable <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> > Take <TKey, TValue>(this Dictionary <TKey, TValue> source, int count)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.Take <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source), count);
 public static Dictionary <TKey2, TElement> ToDictionary <TKey, TValue, TKey2, TElement>(this SortedDictionary <TKey, TValue> .KeyCollection source, NullableSelector <TKey, TKey2> keySelector, NullableSelector <TKey, TElement> elementSelector, IEqualityComparer <TKey2>?comparer)
 => ValueReadOnlyCollectionExtensions.ToDictionary <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey, TKey2, TElement>(new ValueWrapper <TKey, TValue>(source), keySelector, elementSelector, comparer);
 public static bool Contains <TKey, TValue>(this Dictionary <TKey, TValue> source, KeyValuePair <TKey, TValue> value, IEqualityComparer <KeyValuePair <TKey, TValue> >?comparer)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.Contains <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source), value, comparer);
 public static ValueReadOnlyCollectionExtensions.SkipTakeEnumerable <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey> Take <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source, int count)
 => ValueReadOnlyCollectionExtensions.Take <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source), count);
 public static Option <KeyValuePair <TKey, TValue> > ElementAt <TKey, TValue>(this Dictionary <TKey, TValue> source, int index)
     where TKey : notnull
 => ValueReadOnlyCollectionExtensions.ElementAt <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source), index);
 public static bool Any <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source, PredicateAt <TKey> predicate)
 => ValueReadOnlyCollectionExtensions.Any <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source), predicate);
        public static Option <KeyValuePair <TKey, TValue> > Single <TKey, TValue>(this Dictionary <TKey, TValue> source)
            where TKey : notnull
#pragma warning disable HLQ005 // Avoid Single() and SingleOrDefault()
        => ValueReadOnlyCollectionExtensions.Single <ValueWrapper <TKey, TValue>, Dictionary <TKey, TValue> .Enumerator, KeyValuePair <TKey, TValue> >(new ValueWrapper <TKey, TValue>(source));
 public static bool Contains <TKey, TValue>(this SortedDictionary <TKey, TValue> .KeyCollection source, TKey value, IEqualityComparer <TKey>?comparer)
 => ValueReadOnlyCollectionExtensions.Contains <ValueWrapper <TKey, TValue>, SortedDictionary <TKey, TValue> .KeyCollection.Enumerator, TKey>(new ValueWrapper <TKey, TValue>(source), value, comparer);
Exemplo n.º 29
0
 public static bool Any <TSource>(this Queue <TSource> source, PredicateAt <TSource> predicate)
 => ValueReadOnlyCollectionExtensions.Any <ValueWrapper <TSource>, Queue <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), predicate);
 public static bool Contains <TSource>(this ImmutableHashSet <TSource> source, TSource value, IEqualityComparer <TSource>?comparer = default)
 => ValueReadOnlyCollectionExtensions.Contains <ValueWrapper <TSource>, ImmutableHashSet <TSource> .Enumerator, TSource>(new ValueWrapper <TSource>(source), value, comparer);