Method SkipAndTake
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
SkipAndTake<TSource>(IGenerator<TSource>, int, int)
Makes a generator that repeatedly skips over and takes elements from a given generator.
public static IGenerator<TSource> SkipAndTake<TSource>(this IGenerator<TSource> generator, int skipCount, int takeCount)
Parameters
generator
IGenerator<TSource>The source generator.
skipCount
intThe number of elements to skip each cycle.
takeCount
intThe number of elements to take each cycle.
Returns
- IGenerator<TSource>
A new generator.
Type Parameters
TSource
The type of elements of the source generator.
Examples
The following generator will generate 0 1 2 4 5 6 8 9 10...
var generator = Generator
.Count(100)
.TakeAndSkip(3, 1);
Exceptions
- ArgumentNullException
generator
is null.- ArgumentOutOfRangeException
takeCount
is not larger than 0.- ArgumentOutOfRangeException
skipCount
is negative.