Permutations

Lazily computes all permutations of r using Heap's algorithm.

  1. Permutations!Range permutations(Range r)
  2. struct Permutations(Range)
    struct Permutations (
    Range
    ) if (
    isRandomAccessRange!Range &&
    hasLength!Range
    ) {}

Constructors

this
this(Range r)

Members

Functions

popFront
void popFront()

Properties

empty
bool empty [@property getter]
front
auto front [@property getter]

Return Value

A forward range of elements of which are an std.range.indexed view into r.

Examples

import std.algorithm.comparison : equal;
import std.range : iota;
assert(equal!equal(iota(3).permutations,
    [[0, 1, 2],
     [1, 0, 2],
     [2, 0, 1],
     [0, 2, 1],
     [1, 2, 0],
     [2, 1, 0]]));

See Also

Meta

Suggestion Box / Bug Report