Cover

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

If no random number generator is passed to cover, the thread-global RNG rndGen will be used as the source of randomness.

Constructors

this
this(Range input, UniformRNG rng)
Undocumented in source.
this
this(typeof(this) that)
Undocumented in source.

Members

Functions

empty
bool empty()
front
auto ref front()
length
size_t length()
popFront
void popFront()
save
typeof(this) save()

Range primitives.

Examples

int[] a = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ];
foreach (e; cover(a))
{
    writeln(e);
}

// using a specified random number generator
auto gen = new Random(unpredictableSeed);
foreach (e; cover(a, gen))
{
    writeln(e);
}

The alias randomCover is available to ease migration for code written using $(PHOBOSXREF random, randomCover).

Meta