CombinationCollectionT Class

Combinations defines a meta-collection, typically a list of lists, of all possible subsets of a particular size from the set of values.

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

Within the returned set, there is no prescribed order. This follows the mathematical concept of choose.

For example, put 10 dominoes in a hat and pick 5. The number of possible combinations is defined as "10 choose 5", which is calculated as (10!) / ((10 - 5)! * 5!).

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 CombinationCollection<T> : IMetaCollection<T>
Inheritance
Object    CombinationCollectionT
Implements
IMetaCollectionT

Type Parameters

T
The type of the values within the list.

Remarks

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

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

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

Input sets with multiple equal values will generate redundant combinations in proprotion to the likelyhood of outcome.

For example, {A, A, B, B} and a lower index of 3 will generate:

{A, A, B}, {A, A, B}, {A, B, B}, {A, B, B}

Example

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

Constructors

CombinationCollectionT(IListT, Int32) Initializes a new instance of the CombinationCollectionT class.

Create a combination set from the provided list of values.

The upper index is calculated as values.Count, the lower index is user specified.

Collection type defaults to WithoutRepetition

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

Create a combination set from the provided list of values.

The upper index is calculated as values.Count, the lower index is user specified.

Properties

Count Gets the number of unique combinations that are defined in this meta-collection.

This value is mathematically defined as Choose(M, N) where M is the set size and N is the subset size.

This is, M! / (N! * (M-N)!).

LowerIndex Gets the lower index of the meta-collection, equal to the number of items returned each iteration.
Type Gets the type of Combinations set that is generated.
UpperIndex Gets 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 combinations.
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