shuffle

Shuffles elements of r using gen as a shuffler. r must be a random-access range with length. If no RNG is specified, rndGen will be used. Returns the newly-shuffled range, and so is composable:

  1. auto shuffle(Range r, UniformRNG gen)
  2. auto shuffle(Range r)
    shuffle
    (
    Range
    )
    (
    Range r
    )
    if (
    isRandomAccessRange!Range
    )

Examples

// generates the array [0, 1, ..., 10],
// shuffles it, and writes to console
iota(10).array.shuffle.writeln;

A randomShuffle alias has been provided to ease migration from code written using $(PHOBOSXREF random, randomShuffle).

Meta