Method TakeAndSkip
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
TakeAndSkip<TSource>(IGenerator<TSource>, int, int)
Makes a generator that repeatedly takes and skips over elements from a given generator.
public static IGenerator<TSource> TakeAndSkip<TSource>(this IGenerator<TSource> generator, int takeCount, int skipCount)
Parameters
generatorIGenerator<TSource>The source generator.
takeCountintThe number of elements to take each cycle.
skipCountintThe number of elements to skip each cycle.
Returns
- IGenerator<TSource>
A new generator.
Type Parameters
TSourceThe 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
generatoris null.- ArgumentOutOfRangeException
takeCountis not larger than 0.- ArgumentOutOfRangeException
skipCountis negative.