|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Open addressing hash table with double hashing. More...
#include <iostream>#include <cstddef>#include <cstdint>#include <primes.H>#include <dlink.H>#include <tpl_dynArray.H>#include <array_it.H>#include <ahDry.H>#include <hash-dry.H>#include <hashDry.H>#include <hash-fct.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| class | Aleph::ODhashTable< Key, Cmp > |
| Open addressing hash table with double hashing collision resolution. More... | |
| struct | Aleph::ODhashTable< Key, Cmp >::Bucket |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Typedefs | |
| template<typename Key , class Cmp = Aleph::equal_to<Key>> | |
| using | Aleph::SetODhash = ODhashTable< Key, Cmp > |
Open addressing hash table with double hashing.
This file implements an open-addressed hash table that uses double hashing for collision resolution. Double hashing provides excellent distribution and avoids primary and secondary clustering.
When a collision occurs at position h1(k), the probe sequence is:
where h2(k) is a secondary hash function.
| Operation | Average | Worst Case |
|---|---|---|
| insert | O(1) | O(n) |
| search | O(1) | O(n) |
| remove | O(1) | O(n) |
Expected probes: 1/(1-α) for unsuccessful, (1/α)ln(1/(1-α)) for successful where α is the load factor.
The table resizes when load factor exceeds a threshold (default ~0.5). Lower load factors mean faster operations but more memory.
| Feature | ODhashTable | OLhashTable |
|---|---|---|
| Probe | Double hash | Linear |
| Clustering | None | Primary |
| Cache | Good | Excellent |
Definition in file tpl_odhash.H.