Iterators.Permutations<T>(IList<T>, Int32, Boolean) Method

Enumerates the indexes of all permutations of the specified length from a set of items.

Definition

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
C#
public static IEnumerable<T[]> Permutations<T>(
	IList<T> items,
	int length,
	bool lexicographic
)

Parameters

items  IList<T>
A list of items.
length  Int32
The length of each permutation.
lexicographic  Boolean
Specifies whether the permutations should be returned in lexicographic order.

Type Parameters

T

Return Value

IEnumerable<T[]>
A sequence of arrays that contain all permutations of the elements of items. If lexicographic is true, then the permutations are returned in lexicographic order.

Remarks

When lexicographic order is not required, it is faster to set lexicographic to false.

See Also