libBf 0.1
|
The \(A^2\) Bloom filter. More...
#include <bloom_filter_a2.h>
Public Types | |
typedef Core | core_type |
Public Member Functions | |
a2 (core_type &&core, size_t capacity=0) | |
Create an \(A^2\) Bloom filter. | |
template<typename T > | |
void | add (const T &x) |
Add an item to the set. | |
template<typename T > | |
void | remove (const T &x) |
Remove an item from the set. | |
template<typename T > | |
unsigned | count (const T &x) const |
Get the count of an item. | |
const core_type & | core1 () const |
Get the first core. | |
const core_type & | core2 () const |
Get the second core. | |
void | clear () |
Clear all bits. | |
std::string | to_string () const |
Get a string representation of the Bloom filter. | |
Static Public Member Functions | |
static double | k (double f) |
Compute \(k^*\), the optimal number of hash functions for a given false positive rate \(f\). | |
static double | capacity (unsigned k, unsigned m) |
Compute the capacity of a Bloom filter with respect to a given number of hash functions and number of cells in the store. | |
Private Attributes | |
std::size_t | items_ |
Number of items in the first (active) core. | |
std::size_t | capacity_ |
Maximum number of items in the first core. | |
core_type | core1_ |
core_type | core2_ |
The \(A^2\) Bloom filter.
Definition at line 17 of file bloom_filter_a2.h.
bf::a2< Core >::a2 | ( | core_type && | core, |
size_t | capacity = 0 |
||
) | [inline] |
Create an \(A^2\) Bloom filter.
core1 | An rvalue reference to one core. |
capacity | The capacity of a core. The default value of 0 results in a capacity value that is derived from a false positive probability of 1%. |
Definition at line 50 of file bloom_filter_a2.h.
References bf::a2< Core >::capacity(), and bf::a2< Core >::capacity_.
void bf::a2< Core >::add | ( | const T & | x | ) | [inline] |
Add an item to the set.
T | The type of the item to insert. |
x | An instance of type T. |
Reimplemented from bf::bloom_filter< a2< Core > >.
Definition at line 75 of file bloom_filter_a2.h.
static double bf::a2< Core >::capacity | ( | unsigned | k, |
unsigned | m | ||
) | [inline, static] |
Compute the capacity of a Bloom filter with respect to a given number of hash functions and number of cells in the store.
The capacity is defined as the maximum number of items the Bloom filter can hold before the FP rate can no longer be guaranteed.
k | The number of hash functions. |
m | The number of cells in the Bloom filter |
Definition at line 38 of file bloom_filter_a2.h.
Referenced by bf::a2< Core >::a2().
const core_type& bf::a2< Core >::core1 | ( | ) | const [inline] |
Get the first core.
Definition at line 112 of file bloom_filter_a2.h.
const core_type& bf::a2< Core >::core2 | ( | ) | const [inline] |
Get the second core.
Definition at line 119 of file bloom_filter_a2.h.
unsigned bf::a2< Core >::count | ( | const T & | x | ) | const [inline] |
Get the count of an item.
T | The type of the item to query. |
x | An instance of type T. |
Reimplemented from bf::bloom_filter< a2< Core > >.
Definition at line 99 of file bloom_filter_a2.h.
static double bf::a2< Core >::k | ( | double | f | ) | [inline, static] |
Compute \(k^*\), the optimal number of hash functions for a given false positive rate \(f\).
Definition at line 26 of file bloom_filter_a2.h.
Remove an item from the set.
T | The type of the item to delete. |
x | An instance of type T. |
Reimplemented from bf::bloom_filter< a2< Core > >.
std::string bf::a2< Core >::to_string | ( | ) | const [inline] |
Get a string representation of the Bloom filter.
Reimplemented from bf::bloom_filter< a2< Core > >.
Definition at line 131 of file bloom_filter_a2.h.