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.
Selects a random subsample out of r, containing exactly n elements. The order of elements is the same as in the original range. The total length of r must be known. If total is passed in, the total number of elements available to sample is considered to be total. Otherwise, Sample uses r.length.
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:
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.
Selects a random subsample out of r, containing exactly n elements. The order of elements is the same as in the original range. The total length of r must be known. If total is passed in, the total number of elements available to sample is considered to be total. Otherwise, Sample uses r.length.
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.
Partially shuffles the elements of r such that upon returning r[0..n] is a random subset of r and is randomly ordered. r[n..r.length] will contain the elements not in r[0..n]. These will be in an undefined order, but will not be random in the sense that their order after partialShuffle returns will not be independent of their order before partialShuffle was called.
Selects a random subsample out of r, containing exactly n elements. The order of elements is the same as in the original range. The total length of r must be known. If total is passed in, the total number of elements available to sample is considered to be total. Otherwise, Sample uses r.length.
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:
See Source File
$(HAPSRC hap/random/_adaptor.d)
© 2008-2011 Andrei Alexandrescu, 2012-2014 Joseph Rushton Wakeling
Implements algorithms that transform the output of uniform random number generators into other random behaviours, such as shuffling, sampling, and so on. Typically these are implemented as range objects that wrap a provided RNG instance.
As with the random number generators provided elsewhere in this package, the range objects implemented here are implemented as final classes to enforce reference semantics. They also assume that the RNGs they make use of have reference type semantics. User-supplied value-type RNGs may result in incorrect behaviour when used with these objects.