Multicombination Class |
Namespace: Kaos.Combinatorics
public class Multicombination : IComparable, IEnumerable, IComparable<Multicombination>, IEquatable<Multicombination>, IEnumerable<int>
The Multicombination type exposes the following members.
Name | Description | |
---|---|---|
Multicombination |
Initializes an empty multicombination instance.
| |
Multicombination(Int32) |
Initializes a new multicombination of Rank 0 with the supplied number of elements.
| |
Multicombination(Multicombination) |
Initializes a new instance that is copied from the supplied multicombination.
| |
Multicombination(Int32, Int32) |
Initializes a new multicombination of Rank 0
with the supplied number of picks from the supplied number of choices.
| |
Multicombination(Int32, Int32) |
Initializes a new multicombination from elements supplied in source
picked from the supplied number of choices.
| |
Multicombination(Int32, Int32, Int64) |
Initializes a new multicombination of the supplied rank
with the supplied number of picks from the supplied number of choices.
|
Name | Description | |
---|---|---|
Choices |
The available number of integers to choose from.
| |
Item |
Get a element of the Multicombination at the supplied column.
| |
Picks |
Number of elements in the Multicombination.
| |
Rank |
Row index in the ordered Multicombination table.
| |
RowCount |
Count of distinct sequences in the Multicombination table.
|
Name | Description | |
---|---|---|
CompareTo(Object) | Compare two Multicombinations. | |
CompareTo(Multicombination) | Compare two Multicombinations. | |
CopyTo |
Copy the entire sequence to the supplied destination.
| |
Equals(Object) |
Indicate whether two Multicombinations have the same value.
(Overrides ObjectEquals(Object).) | |
Equals(Multicombination) |
Indicate whether two Multicombinations have the same value.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetEnumerator | Enumerate all elements of a Multicombination. | |
GetHashCode | Get the hash oode of the Multicombination. (Overrides ObjectGetHashCode.) | |
GetRows |
Iterate thru all rows of the Multicombination table
for every value of Rank ascending.
| |
GetRowsForPicks |
Iterate thru all rows of all Multicombination tables for every
pick in the range (startPicks..stopPicks).
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
PermuteT |
Apply a Multicombination sequence to rearrange the supplied list or array.
| |
ToString |
Provide a readable form of the Multicombination sequence.
(Overrides ObjectToString.) |
Name | Description | |
---|---|---|
Equality | Indicate whether 2 Multicombinations are equal. | |
GreaterThan | Indicate whether the left Multicombination is greater than
the right Multicombination. | |
GreaterThanOrEqual | Indicate whether the left Multicombination is greater than
or equal to the right Multicombination. | |
Inequality | Indicate whether 2 Multicombinations are not equal. | |
LessThan | Indicate whether the left Multicombination is less than
the right Multicombination. | |
LessThanOrEqual | Indicate whether the left Multicombination is less than
or equal to the right Multicombination. |
The defining variables of a multicombination are n which is the number of possible choices and k which is the number of repeatable picks from those choices. When k is less than n, this is a k-multicombination also known as a k-combination with repetition. Multicombinations are contrasted to combinations where the values in the sequence do not repeat.
The Multicombination class produces k-multicombinations with ascending elements that may repeat as many as k times. While sequence order of the elements is not a general requirement of multicombinations, producing an ascending sequence allows ranking the rows into an ordered table.
Use the Picks property to get the number of elements (k) of a Multicombination taken from a possible number of Choices (n). Use the RowCount property to get the number of distinct possible Multicombination sequences. Use the indexer to get a specified element of the sequence. Use the default enumerator to iterate thru the elements of a Multicombination. Use the Permute method to pick objects from a supplied array of choices based on the current sequence.
Use the Rank property to get or set the row index in a lexicographically ordered Multicombination table of all possible non-descending sequences. Use GetRows to iterate thru all possible sequences of the Multicombination ordered by Rank. Use GetRowsForPicks (startPick, stopPick) to iterate thru every table of all picks in the range (startPick..stopPick).
The default appearance of a Multicombination row is a list of integers (starting at 0) enclosed in braces. The appearance may be tailored 3 ways:
For more information about k-multicombinations, see:
https://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition
Iterating thru new Multicombination (4, 3).GetRows() produces:
{ 0, 0, 0 }
{ 0, 0, 1 }
{ 0, 0, 2 }
{ 0, 0, 3 }
{ 0, 1, 1 }
{ 0, 1, 2 }
{ 0, 1, 3 }
{ 0, 2, 2 }
{ 0, 2, 3 }
{ 0, 3, 3 }
{ 1, 1, 1 }
{ 1, 1, 2 }
{ 1, 1, 3 }
{ 1, 2, 2 }
{ 1, 2, 3 }
{ 1, 3, 3 }
{ 2, 2, 2 }
{ 2, 2, 3 }
{ 2, 3, 3 }
{ 3, 3, 3 }