77#ifndef ALEPH_CUCKOO_FILTER_H
78#define ALEPH_CUCKOO_FILTER_H
98template <
typename T,
size_t Fingerpr
intBits = 8,
size_t EntriesPerBucket = 4>
class Cuckoo_Filter
157 const size_t idx = dist(
rng);
158 std::swap(fp,
slots[idx]);
217 std::optional<std::uint32_t>
seed = std::nullopt)
302 std::uniform_int_distribution<int>
coin(0, 1);
Exception handling system with formatted messages for Aleph-w.
General utility functions and helpers.
Simple dynamic array with automatic resizing and functional operations.
Industrial-grade Cuckoo Filter implementation.
bool contains(const T &item) const
Test membership.
static constexpr Fingerprint fp_mask
Cuckoo_Filter(size_t capacity, std::optional< std::uint32_t > seed=std::nullopt)
Construct a Cuckoo Filter with a given capacity.
double load_factor() const noexcept
Return the load factor of the filter (relative to capacity()).
void clear()
Clear the filter.
bool empty() const noexcept
Return whether the filter contains no items.
bool is_empty() const noexcept
Synonym for empty() in traditional Aleph style.
Fingerprint get_fingerprint(const T &item) const
bool remove(const T &item)
Remove an item from the filter.
size_t size() const noexcept
Return the number of items currently in the filter.
size_t alt_index(size_t i, Fingerprint fp) const
Aleph::Array< Bucket > buckets
static constexpr size_t stash_size
size_t index_hash(const T &item) const noexcept
static constexpr size_t max_kicks
static constexpr double kTargetLoad
Victim stash_[stash_size]
size_t capacity() const noexcept
Return the total number of fingerprint slots (including stash).
bool insert(const T &item)
Insert an item into the filter.
bool append(const T &item)
Alias for insert().
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
unsigned long next_power_of_2(unsigned long x)
In x is not exact power of 2, it returns the next power of 2.
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.
std::decay_t< typename HeadC::Item_Type > T
size_t dft_hash_fct(const Key &key) noexcept
Primary default hash: best speed/quality trade-off.
size_t murmur3hash(const Key &key, std::uint32_t seed)
bool remove(Fingerprint fp)
size_t swap_random_slot(Fingerprint &fp, std::mt19937 &rng)
Fingerprint slots[EntriesPerBucket]
bool insert(Fingerprint fp)
void restore(Fingerprint fp, size_t idx)
bool contains(Fingerprint fp) const
Victim entry: a fingerprint displaced during a failed kick chain.
Dynamic array container with automatic resizing.