|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Probabilistic set membership with Bloom filters. More...
#include <cassert>#include <cstddef>#include <memory>#include <tuple>#include <vector>#include <limits>#include <ctime>#include <utility>#include <gsl/gsl_rng.h>#include <cmath>#include <iostream>#include <ahFunctional.H>#include <bitArray.H>#include <hash-fct.H>#include <tpl_dynSetHash.H>#include <ah-errors.H>Go to the source code of this file.
Classes | |
| class | Aleph::Bloom_Filter< T > |
| Bloom filter implementation. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
Probabilistic set membership with Bloom filters.
This file implements Bloom filters, a space-efficient probabilistic data structure for testing set membership. May return false positives but never false negatives.
A Bloom filter uses k hash functions to map elements to k positions in a bit array of size m. To add an element, set all k bits. To test membership, check if all k bits are set.
Probability of false positive: (1 - e^(-kn/m))^k where n = number of elements, m = bit array size, k = hash functions.
(m/n) * ln(2) ≈ 0.7 * m/n| Operation | Time | Space |
|---|---|---|
| insert | O(k) | O(1) |
| contains | O(k) | O(1) |
| total | - | O(m) bits |
Definition in file bloom-filter.H.