Cachemere
Modular Caching Library for C++
|
1 #ifndef CACHEMERE_BLOOM_FILTER_H
2 #define CACHEMERE_BLOOM_FILTER_H
10 # pragma warning(disable : 4244)
11 # pragma warning(disable : 4018)
14 #include <boost/dynamic_bitset.hpp>
20 #include "hash_mixer.h"
22 namespace cachemere::policy::detail {
44 template<
typename ItemKey>
void add(
const ItemKey& item);
54 template<
typename ItemKey> [[nodiscard]]
bool maybe_contains(
const ItemKey& item)
const;
65 [[nodiscard]]
double saturation()
const noexcept;
68 using BitsetBlock = uint8_t;
69 using BitSet = boost::dynamic_bitset<BitsetBlock>;
71 uint32_t m_cardinality;
78 #include "bloom_filter.hpp"
Probabilistic data structure for representing sets in a space-efficient format.
Definition: bloom_filter.h:29
double saturation() const noexcept
Get the saturation of the filter.
Definition: bloom_filter.hpp:53
BloomFilter(uint32_t cardinality)
Constructor.
Definition: bloom_filter.hpp:8
size_t memory_used() const noexcept
Get an estimate of the memory consumption of the filter.
Definition: bloom_filter.hpp:48
bool maybe_contains(const ItemKey &item) const
Test membership of the specified item.
Definition: bloom_filter.hpp:32
void clear()
Clear the filter while keeping the allocated memory.
Definition: bloom_filter.hpp:27
void add(const ItemKey &item)
Add an item to the filter.
Definition: bloom_filter.hpp:15