Trait reservoir_sampler::ReservoirSampler [−][src]
pub trait ReservoirSampler { type Item; fn sample(&mut self, it: Self::Item) -> (usize, usize, Option<Self::Item>); fn samples(&self) -> &[Option<Self::Item>]; fn lock(self) -> Vec<Option<Self::Item>>; }
Associated Types
Loading content...Required methods
fn sample(&mut self, it: Self::Item) -> (usize, usize, Option<Self::Item>)
[src]
Expand description
A sampler processes exactly one item each time, for the items come in as a stream.
Return
the sample
function return a tuple contains 3 elements:
- a
usize
stands for what random number the current item gets - a
usize
stands for how many items has been passed through so far - an option of item that is replaced by the current item.
fn samples(&self) -> &[Option<Self::Item>]
[src]
Expand description
A reservoir should know which items are held no matter if the sampling process is finished.
fn lock(self) -> Vec<Option<Self::Item>>
[src]
Expand description
End the sampling process. Shuffling the order of the result is allowed.
Implementors
Loading content...