Beispiel #1
0
        public static TSource SingleOrDefault <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, bool> predicate)
        {
            var aggregate = new SingleOrDefaultPredicate <TSource>(predicate);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
        public static bool Contains <TSource>(this ReadOnlyMemory <TSource> source, TSource value)
        {
            var aggregate = new Contains <TSource>(value);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #3
0
        public static bool Contains <TSource>(this ReadOnlyMemory <TSource> source, TSource value, IEqualityComparer <TSource> comparer)
        {
            var aggregate = new ContainsByComparer <TSource>(comparer, value);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #4
0
        public static TSource Single <TSource>(this ReadOnlyMemory <TSource> source)
        {
            var aggregate = new Single <TSource>();

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #5
0
        public static bool All <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, bool> predicate)
        {
            var aggregate = new All <TSource, FuncToIFunc <TSource, bool> >(new FuncToIFunc <TSource, bool>(predicate));

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #6
0
        public static int Count <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, bool> predicate)
        {
            var aggregate = new CountIf <TSource>(predicate);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #7
0
        public static TResult Aggregate <TSource, TAccumulate, TResult>(this ReadOnlyMemory <TSource> source, TAccumulate seed, Func <TAccumulate, TSource, TAccumulate> func, Func <TAccumulate, TResult> resultSelector)
        {
            var aggregate = new FoldForward <TSource, TAccumulate>(func, seed);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(resultSelector(aggregate.GetResult()));
        }
Beispiel #8
0
        public static TSource Aggregate <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, TSource, TSource> func)
        {
            var aggregate = new ReduceForward <TSource>(func);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #9
0
        public static HashSet <TSource> ToHashSet <TSource>(this ReadOnlyMemory <TSource> source, IEqualityComparer <TSource> comparer = null)
        {
            var aggregate = new ToHashSet <TSource>(comparer);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #10
0
        public static Dictionary <TKey, TValue> ToDictionary <TSource, TKey, TValue>(this ReadOnlyMemory <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TValue> elementSelector, IEqualityComparer <TKey> comparer = null)
        {
            var aggregate = new ToDictionary <TSource, TKey, TValue>(keySelector, elementSelector, comparer);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Beispiel #11
0
        public static System.Linq.ILookup <TKey, TElement> ToLookup <TSource, TKey, TElement>(this ReadOnlyMemory <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector, IEqualityComparer <TKey> comparer = null)
        {
            var aggregate = new ToLookup <TSource, TKey, TElement>(comparer, keySelector, elementSelector);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }