fn sample_inplace<R>(rng: &mut R, length: u32, amount: u32) -> IndexVec
where R: Rng + ?Sized {
    debug_assert!(amount <= length);
    let mut indices: Vec<u32> = Vec::with_capacity(length as usize);
    indices.extend(0..length);
    for i in 0..amount {
        let j: u32 = rng.gen_range(i..length);
        indices.swap(i as usize, j as usize);
    }
    indices.truncate(amount as usize);
    debug_assert_eq!(indices.len(), amount as usize);
    IndexVec::from(indices)
}
/// Randomly sample exactly `amount` indices from `0..length`, using an inplace
/// partial Fisher-Yates method.
/// 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 method is not appropriate for large `length` and potentially uses a lot
/// of memory; because of this we only implement for `u32` index (which improves
/// performance in all cases).
///
/// Set-up is `O(length)` time and memory and shuffling is `O(amount)` time.
Randomly sample exactly `amount` indices from `0..length`, using an inplace
partial Fisher-Yates method.
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 method is not appropriate for large `length` and potentially uses a lot
of memory; because of this we only implement for `u32` index (which improves
performance in all cases).

Set-up is `O(length)` time and memory and shuffling is `O(amount)` time.
Randomly sample exactly ` amount ` indices from ` 0 .. length ` using an inplace partial Fisher - Yates method . 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 method is not appropriate for large ` length ` and potentially uses a lot of memory ; because of this we only implement for ` u32 ` index ( which improves performance in all cases ) . Set - up is ` O ( length ) ` time and memory and shuffling is ` O ( amount ) ` time .
fn sample_inplace<R>(rng: &mut R, length: u32, amount: u32) -> IndexVec
where R: Rng + ?Sized {
    debug_assert!(amount <= length);
    let mut indices: Vec<u32> = Vec::with_capacity(length as usize);
    indices.extend(0..length);
    for i in 0..amount {
        let j: u32 = rng.gen_range(i..length);
        indices.swap(i as usize, j as usize);
    }
    indices.truncate(amount as usize);
    debug_assert_eq!(indices.len(), amount as usize);
    IndexVec::from(indices)
}
fn sample_inplace < R > ( rng : & mut R , length : u32 , amount : u32 ) -> IndexVec where R : Rng + ? Sized { debug_assert ! ( amount length ) ; let mut indices : Vec < u32 > = Vec :: with_capacity ( length as usize ) ; indices . extend ( 0 .. length ) ; for i in 0 .. amount { let j : u32 = rng . gen_range ( i .. length ) ; indices . swap ( i as usize , j as usize ) ; } indices . truncate ( amount as usize ) ; debug_assert_eq ! ( indices len ( ) amount as usize ) ; IndexVec :: from ( indices ) }
Randomly sample exactly `amount` indices from `0..length`, using an inplace
partial Fisher-Yates method.
Randomly sample exactly ` amount ` indices from ` 0 .. length ` using an inplace partial Fisher - Yates method .
rng
&mut R
length
u32
amount
u32