Method NextWhile
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
NextWhile<TSource>(IGenerator<TSource>, Func<TSource, bool>)
Generates the elements from the generator while the predicate applied to elements hold an return them in an enumerable. After calling this method, the next element returned by Next (or the current value of Current) will not satisfy the predicate.
public static IEnumerable<TSource> NextWhile<TSource>(this IGenerator<TSource> source, Func<TSource, bool> predicate)
Parameters
sourceIGenerator<TSource>The source generator.
predicateFunc<TSource, bool>The predicate.
Returns
- IEnumerable<TSource>
A new enumerator.
Type Parameters
TSourceThe type of the source generator.
Examples
The enumerable in the following will contain the elements 0, 1, 2, 3:
var list = Generator.Count(100).NextWhile(x => x < 4);