ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
HashMultiset.h File Reference

The multiset on a hash table (exercise 8.10): a counter of occurrences per item, which the insertion of a new item sets to 1 and of an item already there increases by 1, and the removal decreases, removing the item at 0; each operation costs \( O( 1 ) \) expected time. More...

#include "ADS/Contract.h"
#include "ADS/dictionary/ChainedHashTable.h"
#include <algorithm>
#include <concepts>
#include <cstddef>
#include <functional>
#include <optional>
#include <stdexcept>
#include <utility>
#include <vector>
#include "ADS/set/impl/HashMultiset.tpp"

Go to the source code of this file.

Classes

class  ADS::HashMultiset< T, H >
 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) More...

Namespaces

namespace  ADS

Detailed description

The multiset on a hash table (exercise 8.10): a counter of occurrences per item, which the insertion of a new item sets to 1 and of an item already there increases by 1, and the removal decreases, removing the item at 0; each operation costs \( O( 1 ) \) expected time.

The contracts [see Contract.h]: insert() adds one occurrence and remove() takes one away, if any; the invariant is that the size is the sum of the counters, none of which is 0. The operations are defined in HashMultiset.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, exercise 8.10, https://algoritmicamente.it/materiali/libro/capitoli/cap08.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa