Function random_partition_buf

Source
pub fn random_partition_buf<'a, R: MutRandState>(
    rng: &mut R,
    total: usize,
    number_of_parts: usize,
    buf: &'a mut [usize],
) -> &'a mut [usize]
Expand description

Generates a random partition of total into number_of_parts writing the result into the provided buffer.

§Returns

A slice into the input buffer now containing a random partition with elements ordered in descending order.

§Arguments

  • rng - the random number generator used
  • total - the number being partitioned
  • number_of_parts - how many pieces the partition should have
  • buf - a buffer with at least enough space for number_of_parts integers that the returned values are written into.