|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Quotient filter: a cache-friendly probabilistic set with deletion. More...
#include <cstdint>#include <cstddef>#include <cmath>#include <algorithm>#include <utility>#include <ah-errors.H>#include <tpl_array.H>#include <hash-fct.H>Go to the source code of this file.
Classes | |
| class | Aleph::Quotient_Filter< T > |
| Quotient filter for probabilistic set membership with deletion. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Quotient filter: a cache-friendly probabilistic set with deletion.
A quotient filter is a compact, cache-friendly probabilistic data structure for approximate set membership, similar to a Bloom filter but with three critical advantages:
Each element is hashed to a p-bit fingerprint. The fingerprint is split into a quotient (upper q bits) and a remainder (lower r bits). The quotient selects a canonical slot in a 2^q-slot array; the remainder is stored there. Three metadata bits per slot handle collisions via linear probing within contiguous runs:
is_occupied: the canonical slot for some stored quotient.is_continuation: this slot is not the first in its run.is_shifted: this slot holds a remainder shifted from its canonical position.Lookup, insertion and deletion are O(1) amortized when the load factor is bounded below 75%.
The false positive probability is approximately 2^{-r}, where r is the remainder size in bits. Since p = q + r and the table has 2^q slots, choosing a larger r directly reduces the FP rate at the cost of more bits per slot.
| Operation | Average | Worst case |
|---|---|---|
| insert | O(1) | O(n) |
| contains | O(1) | O(n) |
| remove | O(1) | O(n) |
| merge | O(2^q) | O(2^q) |
| space | (r+3) * 2^q bits |
Definition in file quotient-filter.H.