Exemplo n.º 1
0
        public static void ForEach <T>(this IFastEnumerable <T> source, Action <T> next)
        {
            using (var e = source.GetEnumerator())
            {
                while (true)
                {
                    var item = e.TryGetNext(out var success);

                    if (!success)
                    {
                        break;
                    }

                    next(item);
                }
            }
        }
Exemplo n.º 2
0
        public long IFastEnumerable()
        {
            IFastEnumerable <int, int> ife = _array.GetFastEnumerable();
            long total      = 0;
            var  enumerator = ife.Start;
            bool remaining  = true;

loop:
            var i = ife.TryGetNext(ref enumerator, out remaining);

            if (remaining)
            {
                total += i;
                goto loop;
            }
            return(total);
        }
Exemplo n.º 3
0
        public static R Aggregate <T, R>(this IFastEnumerable <T> source, R seed, Func <R, T, R> aggregate)
        {
            var res = seed;

            using (var e = source.GetEnumerator())
            {
                while (true)
                {
                    var item = e.TryGetNext(out var success);

                    if (!success)
                    {
                        break;
                    }

                    res = aggregate(res, item);
                }
            }

            return(res);
        }
Exemplo n.º 4
0
 public WhereFastIterator(IFastEnumerable <T> source, Func <T, bool> predicate)
 {
     _source    = source;
     _predicate = predicate;
 }
Exemplo n.º 5
0
 public SelectFastIterator(IFastEnumerable <T> source, Func <T, R> selector)
 {
     _source   = source;
     _selector = selector;
 }
Exemplo n.º 6
0
 public FastEnumerableToEnumerable(IFastEnumerable <T> source)
 {
     _source = source;
 }
Exemplo n.º 7
0
 public static IFastEnumerable <T> Where <T>(this IFastEnumerable <T> source, Func <T, bool> predicate) => new WhereFastIterator <T>(source, predicate);
Exemplo n.º 8
0
 public static IEnumerable <T> ToEnumerable <T>(this IFastEnumerable <T> source) => new FastEnumerableToEnumerable <T>(source);
Exemplo n.º 9
0
 public static IFastEnumerable <R> Select <T, R>(this IFastEnumerable <T> source, Func <T, R> selector) => new SelectFastIterator <T, R>(source, selector);