Function reservoir_sampling::weighted::a_res [−][src]
pub fn a_res<I, T>(stream: I, sample_len: usize) -> Vec<T> where
I: Iterator<Item = WeightedItem<T>>,
An implementation of Algorithm A-Res
(https://en.wikipedia.org/wiki/Reservoir_sampling#Algorithm_A-Res)
Parameters:
- Iterator of
core::WeightedItem
as source, sample_len
, the size of the sampled reservoir. Returns aVec
of lengthsample_len
In case iterator yields less than sample amount, sample will be filled as much as possible, and returned.