|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Open addressing hash table with linear probing. More...
#include <iostream>#include <cstddef>#include <cstdint>#include <primes.H>#include <dlink.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::OLhashTable< Key, Cmp > |
| Open addressing hash table with linear probing collision resolution. More... | |
| struct | Aleph::OLhashTable< 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::SetOLhash = OLhashTable< Key, Cmp > |
Open addressing hash table with linear probing.
This file implements an open-addressed hash table using linear probing for collision resolution. Linear probing offers excellent cache performance due to sequential memory access patterns.
When a collision occurs at position h(k), the probe sequence is:
Simply checking the next slot until an empty one is found.
| Operation | Average | Worst Case |
|---|---|---|
| insert | O(1) | O(n) |
| search | O(1) | O(n) |
| remove | O(1) | O(n) |
Linear probing suffers from primary clustering: consecutive occupied slots form clusters that grow over time. Keep load factor < 0.5 to minimize this effect.
Definition in file tpl_olhash.H.