Function rand::seq::sample_indices_inplace [−][src]
fn sample_indices_inplace<R>(
rng: &mut R,
length: usize,
amount: usize
) -> Vec<usize> where
R: Rng,
Sample an amount of indices using an inplace partial fisher yates method.
This allocates the entire length
of indices and randomizes only the first amount
.
It then truncates to amount
and returns.
This is better than using a HashMap "cache" when amount >= length / 2
since it does not
require allocating an extra cache and is much faster.