[][src]Function rand::seq::sample_indices_inplace

Important traits for Vec<u8>
fn sample_indices_inplace<R: ?Sized>(
    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.