GraphLib  2.0
une librairie C# pour l’exploitation de graphes en reconnaissance des formes
 All Classes Namespaces Functions Enumerations Enumerator Properties
Matching.Combinations< T > Class Template Reference

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...

Inheritance diagram for Matching.Combinations< T >:
Matching.IMetaCollection< T > Matching.Combinations< T >.Enumerator

Classes

class  Enumerator
 The enumerator that enumerates each meta-collection of the enclosing Combinations class. More...
 

Public Member Functions

 Combinations (IList< T > values, int lowerIndex)
 Create a combination set from the provided list of values. The upper index is calculated as values.Count, the lower index is specified. Collection type defaults to MetaCollectionType.WithoutRepetition More...
 
 Combinations (IList< T > values, int lowerIndex, GenerateOption type)
 Create a combination set from the provided list of values. The upper index is calculated as values.Count, the lower index is specified. More...
 
IEnumerator< IList< T > > GetEnumerator ()
 Gets an enumerator for collecting the list of combinations. More...
 

Protected Member Functions

 Combinations ()
 No default constructor, must provided a list of values and size. More...
 

Properties

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...
 
- Properties inherited from Matching.IMetaCollection< T >
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...
 

Detailed Description

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
TThe type of the values within the list.

Constructor & Destructor Documentation

Matching.Combinations< T >.Combinations ( )
protected

No default constructor, must provided a list of values and size.

Matching.Combinations< T >.Combinations ( IList< T >  values,
int  lowerIndex 
)

Create a combination set from the provided list of values. The upper index is calculated as values.Count, the lower index is specified. Collection type defaults to MetaCollectionType.WithoutRepetition

Parameters
valuesList of values to select combinations from.
lowerIndexThe size of each combination set to return.
Matching.Combinations< T >.Combinations ( IList< T >  values,
int  lowerIndex,
GenerateOption  type 
)

Create a combination set from the provided list of values. The upper index is calculated as values.Count, the lower index is specified.

Parameters
valuesList of values to select combinations from.
lowerIndexThe size of each combination set to return.
typeThe type of Combinations set to generate.

Member Function Documentation

IEnumerator<IList<T> > Matching.Combinations< T >.GetEnumerator ( )

Gets an enumerator for collecting the list of combinations.

Returns
The enumerator.

Property Documentation

long Matching.Combinations< T >.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)!).

int Matching.Combinations< T >.LowerIndex
get

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

GenerateOption Matching.Combinations< T >.Type
get

The type of Combinations set that is generated.

int Matching.Combinations< T >.UpperIndex
get

The upper index of the meta-collection, equal to the number of items in the initial set.


The documentation for this class was generated from the following file: