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 foreach() 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!).
More...
|
long | Count [get] |
| 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)!). More...
|
|
GenerateOption | Type [get] |
| The type of Combinations set that is generated. More...
|
|
int | UpperIndex [get] |
| The upper index of the meta-collection, equal to the number of items in the initial set. More...
|
|
int | LowerIndex [get] |
| The lower index of the meta-collection, equal to the number of items returned each iteration. More...
|
|
long | Count [get] |
| The count of items in the collection. This is not inherited from ICollection since this meta-collection cannot be extended by users. More...
|
|
GenerateOption | Type [get] |
| The type of the meta-collection, determining how the collections are determined from the inputs. More...
|
|
int | UpperIndex [get] |
| The upper index of the meta-collection, which is the size of the input collection. More...
|
|
int | LowerIndex [get] |
| The lower index of the meta-collection, which is the size of each output collection. More...
|
|
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 foreach() 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!).
The MetaCollectionType parameter of the constructor allows for the creation of two types of sets, those with and without repetition in the output set when presented with repetition in the input set.
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}
- Template Parameters
-
T | The type of the values within the list. |