Struct frequency_hashmap::HashMapFrequency
[−]
[src]
pub struct HashMapFrequency<T, N = usize, S = FnvBuildHasher> where
T: Hash + Eq,
N: Num,
S: BuildHasher, { /* fields omitted */ }
A frequency counter backed by a HashMap
.
Methods
impl<T, N, S> HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num,
S: BuildHasher + Default,
[src]
T: Eq + Hash,
N: Num,
S: BuildHasher + Default,
fn new() -> HashMapFrequency<T, N, S>
Creates an empty HashMapFrequency
, a frequency counter backed
by a HashMap.
fn with_capacity(capacity: usize) -> HashMapFrequency<T, N, S>
Creates an empty HashMapFrequency
, a frequency counter backed
by a HashMap with the specified capacity.
The hash map will be able to hold at least capacity
elements without
reallocating. If capacity
is 0, the hash map will not allocate.
```
impl<T, N, S> HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num,
S: BuildHasher,
[src]
T: Eq + Hash,
N: Num,
S: BuildHasher,
fn with_hasher(hash_builder: S) -> HashMapFrequency<T, N, S>
Creates an empty HashMapFrequency
, a frequency counter backed
by a HashMap which will use the given hash builder to hash
keys.
The created map has the default initial capacity.
Warning: hash_builder
is normally randomly generated, and
is designed to allow HashMaps to be resistant to attacks that
cause many collisions and very poor performance. Setting it
manually using this function can expose a DoS attack vector.
```
fn with_capacity_and_hasher(
capacity: usize,
hash_builder: S
) -> HashMapFrequency<T, N, S>
capacity: usize,
hash_builder: S
) -> HashMapFrequency<T, N, S>
Creates an empty HashMapFrequency
, a frequency counter backed
by a HashMap with the specified capacity, using hasher
to hash the keys.
The hash map will be able to hold at least capacity
elements without
reallocating. If capacity
is 0, the hash map will not allocate.
Warning: hasher
is normally randomly generated, and
is designed to allow HashMaps to be resistant to attacks that
cause many collisions and very poor performance. Setting it
manually using this function can expose a DoS attack vector.
fn len(&self) -> usize
Returns the number of elements that have been counted.
fn is_empty(&self) -> bool
Returns true if the counter contains no elements.
fn reserve(&mut self, additional: usize)
Trait Implementations
impl<'t, T, N, S> Frequency<'t, T> for HashMapFrequency<T, N, S> where
T: 't + Eq + Hash,
N: 't + Num + Clone,
S: 't + BuildHasher,
[src]
T: 't + Eq + Hash,
N: 't + Num + Clone,
S: 't + BuildHasher,
type N = N
The type used to record counts.
type Iter = Iter<'t, T, Self::N>
The type of an iterator over item-count pairs.
type Items = Keys<'t, T, Self::N>
The type of an iterator over items.
type Counts = Values<'t, T, Self::N>
The type of an iterator over counts.
fn count(&self, key: &T) -> Self::N
Returns the count of an item.
fn increment(&mut self, value: T)
Increments the count for an item.
fn iter(&'t self) -> Self::Iter
An iterator visiting all key-value pairs. Iterator element type is (&'t T, &'t usize)
. Read more
fn items(&'t self) -> Self::Items
An iterator visiting all keys in arbitrary order. Iterator element type is &'t T
. Read more
fn counts(&'t self) -> Self::Counts
An iterator visiting all counts in arbitrary order. Iterator element type is &'t usize
. Read more
impl<T, N, S> Default for HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num,
S: BuildHasher + Default,
[src]
T: Eq + Hash,
N: Num,
S: BuildHasher + Default,
fn default() -> HashMapFrequency<T, N, S>
Creates an empty HashMapFrequency<T, V, S>
, a frequency counter backed
by a HashMap with the Default
value for the hasher.
impl<T, N, S> Extend<T> for HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num + Clone,
S: BuildHasher,
[src]
T: Eq + Hash,
N: Num + Clone,
S: BuildHasher,
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<T, N, S> FromIterator<T> for HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num + Clone,
S: BuildHasher + Default,
[src]
T: Eq + Hash,
N: Num + Clone,
S: BuildHasher + Default,
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<'t, T, N, S> IntoIterator for &'t HashMapFrequency<T, N, S> where
T: 't + Eq + Hash,
N: 't + Num + Clone,
S: 't + BuildHasher,
[src]
T: 't + Eq + Hash,
N: 't + Num + Clone,
S: 't + BuildHasher,
type Item = <<HashMapFrequency<T, N, S> as Frequency<'t, T>>::Iter as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = <HashMapFrequency<T, N, S> as Frequency<'t, T>>::Iter
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<T, N, S> AsRef<HashMap<T, N, S>> for HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num,
S: BuildHasher,
[src]
T: Eq + Hash,
N: Num,
S: BuildHasher,
impl<T, N, S> AsMut<HashMap<T, N, S>> for HashMapFrequency<T, N, S> where
T: Eq + Hash,
N: Num,
S: BuildHasher,
[src]
T: Eq + Hash,
N: Num,
S: BuildHasher,