public static async Task ForEachAsync <T>(this IAsyncFastEnumerable <T> source, Func <T, Task> next) { var e = source.GetAsyncEnumerator(); try { while (await e.WaitForNextAsync().ConfigureAwait(false)) { while (true) { var item = e.TryGetNext(out var success); if (!success) { break; } await next(item).ConfigureAwait(false); } } } finally { await e.DisposeAsync().ConfigureAwait(false); } }
public static async Task <R> Aggregate <T, R>(this IAsyncFastEnumerable <T> source, R seed, Func <R, T, Task <R> > aggregate) { var res = seed; var e = source.GetAsyncEnumerator(); try { while (await e.WaitForNextAsync().ConfigureAwait(false)) { while (true) { var item = e.TryGetNext(out var success); if (!success) { break; } res = await aggregate(res, item).ConfigureAwait(false); } } } finally { await e.DisposeAsync().ConfigureAwait(false); } return(res); }
public WhereFastIteratorWithTask(IAsyncFastEnumerable <T> source, Func <T, Task <bool> > predicate) { _source = source; _predicate = predicate; }
public WhereFastIterator(IAsyncFastEnumerable <T> source, Func <T, bool> predicate) { _source = source; _predicate = predicate; }
public SelectFastIteratorWithTask(IAsyncFastEnumerable <T> source, Func <T, Task <R> > selector) { _source = source; _selector = selector; }
public SelectFastIterator(IAsyncFastEnumerable <T> source, Func <T, R> selector) { _source = source; _selector = selector; }
public AsyncFastEnumerableToAsyncEnumerable(IAsyncFastEnumerable <T> source) { _source = source; }
public static IAsyncFastEnumerable <T> Where <T>(this IAsyncFastEnumerable <T> source, Func <T, Task <bool> > predicate) => new WhereFastIteratorWithTask <T>(source, predicate);
public static IAsyncEnumerable <T> ToAsyncEnumerable <T>(this IAsyncFastEnumerable <T> source) => new AsyncFastEnumerableToAsyncEnumerable <T>(source);
public static IAsyncFastEnumerable <R> Select <T, R>(this IAsyncFastEnumerable <T> source, Func <T, Task <R> > selector) => new SelectFastIteratorWithTask <T, R>(source, selector);