Table of Contents

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

generator IGenerator<TSource>

The source generator.

takeCount int

The number of elements to take each cycle.

skipCount int

The number of elements to skip 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.