Click or drag to resize

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:

  • Map each element to a different value using the combinatoric's default enumerator or its indexer.
  • Use the Permute method and output the rearranged values.
  • Define a subclass of the combinatoric and override ToString().
  • Classes
      ClassDescription
    Public classCode exampleCombination
    Represents an ascending sequence of distinct picks from a supplied range.
    Public classCombinatoric
    Provides static methods for combinatorics.
    Public classCode exampleMulticombination
    Represents an ascending sequence of repeating picks from a supplied range.
    Public classCode examplePermutation
    Represents a specific arrangement of distinct picks from a supplied range.
    Public classCode exampleProduct
    Represents a join of values taken from a supplied array of ranges.