Click or drag to resize

Multicombination Class

Represents an ascending sequence of repeating picks from a supplied range.
Inheritance Hierarchy
SystemObject
  Kaos.CombinatoricsMulticombination

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 6.0.0.0
Syntax
C#
public class Multicombination : IComparable, 
	IEnumerable, IComparable<Multicombination>, IEquatable<Multicombination>, 
	IEnumerable<int>

The Multicombination type exposes the following members.

Constructors
  NameDescription
Public methodMulticombination
Initializes an empty multicombination instance.
Public methodMulticombination(Int32)
Initializes a new multicombination of Rank 0 with the supplied number of elements.
Public methodMulticombination(Multicombination)
Initializes a new instance that is copied from the supplied multicombination.
Public methodCode exampleMulticombination(Int32, Int32)
Initializes a new multicombination of Rank 0 with the supplied number of picks from the supplied number of choices.
Public methodCode exampleMulticombination(Int32, Int32)
Initializes a new multicombination from elements supplied in source picked from the supplied number of choices.
Public methodCode exampleMulticombination(Int32, Int32, Int64)
Initializes a new multicombination of the supplied rank with the supplied number of picks from the supplied number of choices.
Top
Properties
  NameDescription
Public propertyChoices
The available number of integers to choose from.
Public propertyCode exampleItem
Get a element of the Multicombination at the supplied column.
Public propertyPicks
Number of elements in the Multicombination.
Public propertyCode exampleRank
Row index in the ordered Multicombination table.
Public propertyRowCount
Count of distinct sequences in the Multicombination table.
Top
Methods
  NameDescription
Public methodCompareTo(Object)
Compare two Multicombinations.
Public methodCompareTo(Multicombination)
Compare two Multicombinations.
Public methodCopyTo
Copy the entire sequence to the supplied destination.
Public methodEquals(Object)
Indicate whether two Multicombinations have the same value.
(Overrides ObjectEquals(Object).)
Public methodEquals(Multicombination)
Indicate whether two Multicombinations have the same value.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetEnumerator
Enumerate all elements of a Multicombination.
Public methodGetHashCode
Get the hash oode of the Multicombination.
(Overrides ObjectGetHashCode.)
Public methodCode exampleGetRows
Iterate thru all rows of the Multicombination table for every value of Rank ascending.
Public methodCode exampleGetRowsForPicks
Iterate thru all rows of all Multicombination tables for every pick in the range (startPicks..stopPicks).
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberCode examplePermuteT
Apply a Multicombination sequence to rearrange the supplied list or array.
Public methodCode exampleToString
Provide a readable form of the Multicombination sequence.
(Overrides ObjectToString.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Indicate whether 2 Multicombinations are equal.
Public operatorStatic memberGreaterThan
Indicate whether the left Multicombination is greater than the right Multicombination.
Public operatorStatic memberGreaterThanOrEqual
Indicate whether the left Multicombination is greater than or equal to the right Multicombination.
Public operatorStatic memberInequality
Indicate whether 2 Multicombinations are not equal.
Public operatorStatic memberLessThan
Indicate whether the left Multicombination is less than the right Multicombination.
Public operatorStatic memberLessThanOrEqual
Indicate whether the left Multicombination is less than or equal to the right Multicombination.
Top
Remarks

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

Examples

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 }

See Also