Skip to main content

FrequencyTable

Struct FrequencyTable 

Source
pub struct FrequencyTable<T: Hash + Eq + Clone> { /* private fields */ }
Expand description

Tracks the frequency of items.

Implementations§

Source§

impl<T: Hash + Eq + Clone> FrequencyTable<T>

Source

pub fn new() -> Self

Creates a new empty frequency table.

Source

pub fn record(&mut self, item: T)

Records one occurrence of item.

Source

pub fn freq(&self, item: &T) -> u64

Returns the frequency of item.

Source

pub fn most_frequent(&self) -> Option<(&T, u64)>

Returns the item with the highest frequency.

Source

pub fn total(&self) -> u64

Returns the total number of recordings.

Source

pub fn distinct(&self) -> usize

Returns the number of distinct items.

Trait Implementations§

Source§

impl<T: Hash + Eq + Clone> Default for FrequencyTable<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FrequencyTable<T>

§

impl<T> RefUnwindSafe for FrequencyTable<T>
where T: RefUnwindSafe,

§

impl<T> Send for FrequencyTable<T>
where T: Send,

§

impl<T> Sync for FrequencyTable<T>
where T: Sync,

§

impl<T> Unpin for FrequencyTable<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for FrequencyTable<T>

§

impl<T> UnwindSafe for FrequencyTable<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.