Kaos.Combinatorics Namespace |
The KaosCombinatorics library consists of 4 classes that provide 4 different approaches to generating ordered sequences of numbers. These sequences may be used to permute (rearrange) other lists of objects. Combinatorics are useful for software testing by allowing the generation of various types of possible combinations of input. Other uses include solving mathematical problems, games of chance, and cryptography.
Two key features this library provides are unranking and ranking for every combinatoric. Unranking is the ability to quickly retrieve any row in the combinatoric's lexicographically ordered table by setting its Rank property, or by supplying the rank to a constructor. Ranking is where an array of integers is supplied to a conbinatoric's constructor giving its place in the ordered table by accessing the Rank property.
As with the Rank property, the classes in this library have an identical interface wherever possible so that the techniques used on one class can be applied to the others. Each class makes available a sequence of zero-based integers which represents the current row of its combinatoric. The elements of this row may be accessed using the class's indexer or default enumerator. Each class has a GetRows method for enumerating over a table with the given starting row. Each class has a RowCount property that returns the range of values of Rank. All classes except Product have Choices and Picks properties where Picks is the number of elements in the combinatoric taken from a possible number of Choices.
The default appearance of a combinatoric row is a list of integers (starting at 0) enclosed in braces. This appearance may be tailored 3 ways:
Class | Description | |
---|---|---|
Combination |
Represents an ascending sequence of distinct picks from a supplied range.
| |
Combinatoric | Provides static methods for combinatorics. | |
Multicombination |
Represents an ascending sequence of repeating picks from a supplied range.
| |
Permutation |
Represents a specific arrangement of distinct picks from a supplied range.
| |
Product |
Represents a join of values taken from a supplied array of ranges.
|