Template Class HashMultiset

Class Documentation

template<class T, class H = std::hash<T>>
class HashMultiset

a multiset on a hash table, a counter of occurrences per item: the insertion of a new item sets it to 1, of an item already there adds 1, the removal subtracts 1 and removes the item at 0 (exercise 8.10)

Public Types

using Item = T

the type of the items

using value_type = std::pair<T, std::size_t>
using const_iterator = typename ChainedHashTable<T, std::size_t, Chain::FRONT, H>::const_iterator
using iterator = const_iterator

Public Functions

HashMultiset(void)
std::size_t size(void) const

the number of items, each counted as many times as it occurs

std::size_t distinct(void) const

the number of distinct items

bool empty(void) const
bool contains(const T &x) const
std::size_t count(const T &x) const

the occurrences of x

void insert(const T &x)
Post:

one occurrence of x more

void remove(const T &x)

removes one occurrence of x, if there is one

Post:

one occurrence of x less, or none

template<class F>
void forEach(F &&f) const

f( x , c ) on the distinct items and their occurrences

inline const_iterator begin(void) const
inline const_iterator end(void) const
inline const_iterator cbegin(void) const
inline const_iterator cend(void) const