Struct amadeus::MostFrequent[][src]

pub struct MostFrequent<T: Hash + Eq + Clone> { /* fields omitted */ }

This data structure tracks the n most frequently seen elements in a stream, using only O(n) space. It is approximate.

The formulation used is described here.

while an item i from the input stream arrives:
    if H[i] exists
        increment the value associated with H[i]
    elsif number of items in H < k
        put H[i] into map with value of base + 1
    elseif there exists an entry j with a value of base
        remove j and put H[i] into map with value of base + 1
    else
        increment base
endwhile

See A Simple Algorithm for Finding Frequent Elements in Streams and Bags for more information.

Methods

impl<T: Hash + Eq + Clone> MostFrequent<T>
[src]

Create an empty MostFrequent data structure with the specified capacity.

The n most frequent elements we have capacity to track.

"Visit" an element.

Important traits for MostFrequentIter<'a, T>

An iterator visiting all elements and their counts in descending order of frequency. The iterator element type is (&'a T, usize).

Trait Implementations

impl<T: Clone + Hash + Eq + Clone> Clone for MostFrequent<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, T: Hash + Eq + Clone + Debug> Debug for MostFrequent<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Hash + Eq + Clone> Sum for MostFrequent<T>
[src]

Method which takes an iterator and generates Self from the elements by "summing up" the items. Read more

impl<T: Hash + Eq + Clone> Add for MostFrequent<T>
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<T: Hash + Eq + Clone> AddAssign for MostFrequent<T>
[src]

Performs the += operation.

Auto Trait Implementations

impl<T> Send for MostFrequent<T> where
    T: Send

impl<T> Sync for MostFrequent<T> where
    T: Sync