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

The SET on a hash table whose foreach follows the order of insertion (exercise 8.9): a LIST keeps the items in that order and the table maps each item to its position, so insert(), remove() and contains() take \( O( 1 ) \) expected time and forEach() \( O( n ) \). More...

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

Go to the source code of this file.

Classes

class  ADS::LinkedHashSet< T, H >
 a set on a hash table whose foreach follows the order of insertion: a LIST keeps the items in that order and the table maps each item to its position, so insert(), remove() and contains() take \( O( 1 ) \) expected time and forEach() \( O( n ) \) (exercise 8.9) More...

Namespaces

namespace  ADS

Detailed description

The SET on a hash table whose foreach follows the order of insertion (exercise 8.9): a LIST keeps the items in that order and the table maps each item to its position, so insert(), remove() and contains() take \( O( 1 ) \) expected time and forEach() \( O( n ) \).

The contracts [see Contract.h]: after insert() the item is there and after remove() it is not; the invariant is that each item of the list is indexed at its own position and the table has no other item. The operations are defined in LinkedHashSet.tpp.

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