Table of Contents

Method Combinations

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

Combinations<T>(IEnumerable<T>, int)

Generates all combinations of m elements selected from the list.

public static IEnumerable<T[]> Combinations<T>(this IEnumerable<T> list, int m)

Parameters

list IEnumerable<T>

The list to select from.

m int

The number of elements in each combination.

Returns

IEnumerable<T[]>

IEnumerable<T[]>.

Type Parameters

T

The type of elements in the list.

Exceptions

ArgumentOutOfRangeException

m;must be nonnegative or m;must be smaller than n

Combinations<T>(int, int, Func<int[], T>)

Generates all combinations of m elements from n and applies a selector to each.

public static IEnumerable<T> Combinations<T>(int m, int n, Func<int[], T> select)

Parameters

m int

The number of elements in each combination.

n int

The total number of elements to choose from.

select Func<int[], T>

A function applied to each combination's index array to produce the result.

Returns

IEnumerable<T>

An enumerable of results for all C(n, m) combinations.

Type Parameters

T

The type of the result.

Exceptions

ArgumentOutOfRangeException

m or n is negative, or m is greater than n.

ArgumentNullException

select is null.