38#include <gtest/gtest.h>
54 return static_cast<size_t>(item);
59 return static_cast<size_t>(item) +
static_cast<size_t>(
seed);
84 for (
int i = 0; i < 50; ++i)
120 for (
const auto h : hashes)
143 for (
int i = 0; i < 20; ++i)
150 for (
int i = 0; i < 20; ++i)
154 for (
int i = 0; i < 20; ++i)
192 FAIL() <<
"expected std::domain_error";
194 catch (
const std::domain_error &e)
196 const string msg = e.what();
197 EXPECT_NE(msg.find(
"Bloom filter have different hashes"), string::npos);
204 for (
int i = 0; i < 50; ++i)
207 const auto x = f.
get_x();
Probabilistic set membership with Bloom filters.
Bloom filter implementation.
size_t expected_size(const size_t x) const noexcept
Estimate the number of inserted items from the number of bits set.
size_t get_n() const noexcept
Return the number of insertions performed on the filter.
DynList< size_t > set_bits() const
Return the indexes of bits set to 1.
size_t get_m() const noexcept
Return the number of bits of the filter.
bool contains(const T &item) const
Test membership.
DynList< size_t > hash_seeds() const
Return the internally generated per-hash seeds.
auto & insert(const T &item)
Insert an item.
DynList< size_t > hashes(const T &item) const
Return the bit positions used by item.
size_t get_k() const noexcept
Return the number of hash functions used by the filter.
size_t get_x() const noexcept
Return the number of bits set to 1.
Dynamic singly linked list with functional programming support.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Itor find(const Itor &beg, const Itor &end, const T &value)
Find the first element equal to a value.
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.