Function rand::seq::index::sample_floyd

source ·
fn sample_floyd<R>(rng: &mut R, length: u32, amount: u32) -> IndexVec
where R: Rng + ?Sized,
Expand description

Randomly sample exactly amount indices from 0..length, using Floyd’s combination algorithm.

The output values are fully shuffled. (Overhead is under 50%.)

This implementation uses O(amount) memory and O(amount^2) time.