Table of Contents

Method Group

Namespace
Gamelogic.Extensions.Algorithms
Assembly
Gamelogic.Extensions.dll

Group<TSource>(IGenerator<TSource>, IGenerator<int>)

Makes a generator that generates groups of items from the source generator.

public static IGenerator<IList<TSource>> Group<TSource>(this IGenerator<TSource> generator, IGenerator<int> groupSizeGenerator)

Parameters

generator IGenerator<TSource>

The source generator.

groupSizeGenerator IGenerator<int>

The generator used to determine the size of the groups to return.

Returns

IGenerator<IList<TSource>>

IGenerator<IEnumerable<TSource>>.

Type Parameters

TSource

The type of the source generator.

Exceptions

ArgumentNullException

generator

ArgumentOutOfRangeException

groupSizeGenerator;Argument must be positive.

Group<TSource>(IGenerator<TSource>, int)

Makes a generator that returns groups of elements from the source generator.

public static IGenerator<IList<TSource>> Group<TSource>(this IGenerator<TSource> generator, int groupSize)

Parameters

generator IGenerator<TSource>

The source generator.

groupSize int

The size of the groups.

Returns

IGenerator<IList<TSource>>

IGenerator<IEnumerable<TSource>>.

Type Parameters

TSource

The type of the source generator.

Remarks

For example, if the source generator generates 0, 1, 2, 3, ... and the group size is 2 then the result generator will return groups (0, 1), (2, 3), ...

Exceptions

ArgumentNullException

generator

ArgumentOutOfRangeException

groupSize;Argument must be positive.