makeCombinationsRepeat

Lazily computes all k-combinations of r with repetitions. A k-combination with repetitions, or k-multicombination, or multisubset of size k from a set S is given by a sequence of k not necessarily distinct elements of S, where order is not taken into account. Imagine this as the cartesianPower filtered for only ordered items.

While generating a new combination with repeats is in O(k), the number of combinations with repeats is binomial(n + k - 1, k).

  1. CombinationsRepeat!T combinationsRepeat(size_t n, size_t k)
  2. IndexedRoR!(CombinationsRepeat!T, Range) combinationsRepeat(Range r, size_t k)
  3. CombinationsRepeat!T makeCombinationsRepeat(Allocator alloc, size_t n, size_t repeat)
    makeCombinationsRepeat
    (
    T = uint
    Allocator
    )
    (
    auto ref Allocator alloc
    ,
    size_t n
    ,
    size_t repeat
    )
    if (
    isUnsigned!T &&
    T.sizeof <= size_t.sizeof
    )

Parameters

n size_t

number of elements (|r|)

alloc Allocator

custom Allocator

Return Value

Type: CombinationsRepeat!T

Forward range, which yields the k-multicombinations items

See Also

Meta