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); } } }
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); }
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); }
public WhereFastIterator(IFastEnumerable <T> source, Func <T, bool> predicate) { _source = source; _predicate = predicate; }
public SelectFastIterator(IFastEnumerable <T> source, Func <T, R> selector) { _source = source; _selector = selector; }
public FastEnumerableToEnumerable(IFastEnumerable <T> source) { _source = source; }
public static IFastEnumerable <T> Where <T>(this IFastEnumerable <T> source, Func <T, bool> predicate) => new WhereFastIterator <T>(source, predicate);
public static IEnumerable <T> ToEnumerable <T>(this IFastEnumerable <T> source) => new FastEnumerableToEnumerable <T>(source);
public static IFastEnumerable <R> Select <T, R>(this IFastEnumerable <T> source, Func <T, R> selector) => new SelectFastIterator <T, R>(source, selector);