Struct pdatastructs::TopK
[−]
[src]
pub struct TopK<T> where
T: Clone + Eq + Hash + Ord, { /* fields omitted */ }
Top-K implementation.
This data structure keeps the k
most frequent data points of a stream.
Methods
impl<T> TopK<T> where
T: Clone + Eq + Hash + Ord,
[src]
T: Clone + Eq + Hash + Ord,
fn new(k: usize, cms: CountMinSketch) -> TopK<T>
[src]
Create new Top-K data structure.
k
: number of elements to remembercms
: CountMinSketch that is used for guessing the frequency of elements not currently hold. Refer to its documentation about parameter selection.
Panics if k == 0
.
fn k(&self) -> usize
[src]
Number of data points to remember.
fn add(&mut self, obj: T)
[src]
Observe a data point.
fn values(&self) -> Vec<T>
[src]
Returns top-k values.
The result may contain less than k
values if less than k
unique data points where
observed.
fn is_empty(&self) -> bool
[src]
Check whether the sampler is empty (i.e. no data points observer so far)
fn clear(&mut self)
[src]
Clear sampler, so that it behaves like it never observed any data points.
Trait Implementations
impl<T: Clone> Clone for TopK<T> where
T: Clone + Eq + Hash + Ord,
[src]
T: Clone + Eq + Hash + Ord,
fn clone(&self) -> TopK<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Debug for TopK<T> where
T: Clone + Eq + Hash + Ord,
[src]
T: Clone + Eq + Hash + Ord,
impl<T> Extend<T> for TopK<T> where
T: Clone + Eq + Hash + Ord,
[src]
T: Clone + Eq + Hash + Ord,
fn extend<S: IntoIterator<Item = T>>(&mut self, iter: S)
[src]
Extends a collection with the contents of an iterator. Read more