PermutationCollectionT Class

Permutations defines a meta-collection, typically a list of lists, of all possible orderings of a set of values.

This list is enumerable and allows the scanning of all possible permutations using a simple For Each loop.

Definition

Namespace: DevCase.Core.Math.Combinatorics
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public sealed class PermutationCollection<T> : IMetaCollection<T>
Inheritance
Object    PermutationCollectionT
Implements
IMetaCollectionT

Type Parameters

T
The type of the values within the list.

Remarks

When given a input collect {A, A, B} and lower index of 2, the following sets are generated:

MetaCollectionType.WithRepetition => {A, A, B}, {A, B, A}, {A, A, B}, {A, B, A}, {B, A, A}, {B, A, A}

MetaCollectionType.WithoutRepetition => {A, A, B}, {A, B, A}, {B, A, A}

When generating non-repetition sets, ordering is based on the lexicographic ordering of the lists based on the provided Comparer. If no comparer is provided, then T must be IComparable on T.

When generating repetition sets, no comparisions are performed and therefore no comparer is required and T does not need to be IComparable.

Example

This is a code example.
C#
No code example is currently available or this language may not be supported.

Constructors

PermutationCollectionT(IListT) Initializes a new instance of the PermutationCollectionT class.

Create a permutation set from the provided list of values.

The values T must implement IComparable.

If T does not implement IComparable use a constructor with an explict IComparer.

The repetition type defaults to WithoutRepetition

PermutationCollectionT(IListT, MetaCollectionType) Initializes a new instance of the PermutationCollectionT class.

Create a permutation set from the provided list of values.

If type is WithoutRepetition, then values (T) must implement IComparable.

If T does not implement IComparable use a constructor with an explict IComparer.

PermutationCollectionT(IListT, IComparerT) Initializes a new instance of the PermutationCollectionT class.

Create a permutation set from the provided list of values.

The values will be compared using the supplied IComparer.

The repetition type defaults to WithoutRepetition

Properties

Count The count of all permutations that will be returned.

If type is WithoutRepetition, then this does not double count permutations with multiple identical values.

I.e. count of permutations of "AAB" will be 3 instead of 6. If type is WithRepetition, then this is all combinations and is therefore N!, where N is the number of values.

LowerIndex The lower index of the meta-collection, equal to the number of items returned each iteration.

For Permutation, this is always equal to the UpperIndex.

Type The type of Permutations set that is generated.
UpperIndex The upper index of the meta-collection, equal to the number of items in the initial set.

Methods

Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
GetEnumerator Gets an enumerator for collecting the list of permutations.
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetType Gets the Type of the current instance.
(Inherited from Object)
ToString Returns a string that represents the current object.
(Inherited from Object)

Extension Methods

CanConvertTo Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
CanConvertToT Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
ConvertToT Converts an object to the specified target type.

If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions)

ConvertToT Converts an object to the specified target type.

If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions)

IsDisposable Determines whether the specified object is a disposable type (i.e., it implements IDisposable interface).
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
ThrowIfNullTException Throws the specified exception if the source object is null.
(Defined by ObjectExtensions)

See Also