Function reservoir_sampling::unweighted::core::l[][src]

pub fn l<R: ?Sized, I, T>(iter: I, sample: &mut [T], rng: &mut R) where
    R: Rng,
    I: Iterator<Item = T>, 

An implementation of Algorithm L (https://en.wikipedia.org/wiki/Reservoir_sampling#An_optimal_algorithm)

Parameters:

  • Type implementing std::iter::Iterator as source,
  • Mutable array slice (i.e. &mut [T]) as sample array (i.e. where sampled data is stored)
  • Type implementing rand::Rng for random number generation. In case iterator yields less than sample amount, sample will be filled as much as possible, and returned.