pub fn sample_array<R, const N: usize>(
rng: &mut R,
len: usize,
) -> Option<[usize; N]>where
R: Rng + ?Sized,
Expand description
Randomly sample exactly N
distinct indices from 0..len
, and
return them in random order (fully shuffled).
This is implemented via Floyd’s algorithm. Time complexity is O(N^2)
and memory complexity is O(N)
.
Returns None
if (and only if) N > len
.