The OpenD Programming Language

randomCover

Covers a given range r in a random manner, i.e. goes through each element of r once and only once, just in a random order. r must be a random-access range with length.

If no random number generator is passed to randomCover, the thread-global RNG rndGen will be used internally.

  1. auto randomCover(Range r, UniformRNG rng)
  2. auto randomCover(Range r)
    randomCover
    (
    Range
    )
    (
    Range r
    )

Parameters

r Range

random-access range to cover

Return Value

Type: auto

Range whose elements consist of the elements of r, in random order. Will be a forward range if both r and rng are forward ranges, an input range otherwise.

Examples

import std.algorithm.comparison : equal;
import std.range : iota;
auto rnd = MinstdRand0(42);

version (D_LP64) // https://issues.dlang.org/show_bug.cgi?id=15147
assert(10.iota.randomCover(rnd).equal([7, 4, 2, 0, 1, 6, 8, 3, 9, 5]));

Meta