4#ifndef _Stroika_Foundation_Cache_BloomFilter_h_
5#define _Stroika_Foundation_Cache_BloomFilter_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
12#include "Stroika/Foundation/Common/Common.h"
14#include "Stroika/Foundation/Containers/Sequence.h"
15#include "Stroika/Foundation/Containers/Set.h"
16#include "Stroika/Foundation/Cryptography/Digest/Hash.h"
44 using HashResultType = uint64_t;
85 static unsigned int OptimizeNumberOfHashFunctions (
size_t setSize,
size_t bitSize);
115 nonvirtual
void clear ();
138 nonvirtual Statistics GetStatistics ()
const;
141 vector<HashFunctionType> fHashFunctions_;
143 unsigned int fActualAddCalls_{};
144 unsigned int fApparentlyDistinctAddCalls_{};
149 template <
typename T>
150 struct BloomFilter<T>::Statistics {
151 size_t fHashFunctions;
154 unsigned int fActualAddCalls;
155 unsigned int fApparentlyDistinctAddCalls;
164 nonvirtual
double GetFractionFull ()
const;
175 nonvirtual Characters::String
ToString ()
const;
185#include "BloomFilter.inl"
a Bloom filter is a probablistic set, which returns either "probably in set" or "definitely not in se...
static constexpr double kDefaultDesiredFalsePositivityRate
kDefaultDesiredFalsePositivityRate is used for constructors given expectedMaxSetSize to compute the a...
nonvirtual bool ProbablyContains(Common::ArgByValueType< T > elt) const
returns true if this (probably) Contains 'elt' - and false otherwise.
nonvirtual bool Add(Common::ArgByValueType< T > elt)
static double ProbabilityOfFalsePositive(size_t hashFunctionCount, size_t bitCount, size_t nElementsInsertedSoFar)
static Containers::Sequence< HashFunctionType > DeriveIndependentHashFunctions(const HashFunctionType &h, size_t repeatCount)
function< HashResultType(T)> HashFunctionType
LRUCache implements a simple least-recently-used caching strategy, with optional hashing (of keys) to...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
STRING_TYPE ToString(FLOAT_TYPE f, const ToStringOptions &options={})
conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & > ArgByValueType
This is an alias for 'T' - but how we want to pass it on stack as formal parameter.
Simple wrapper on (cryptographic) digest algorithms with fewer knobs, and easier construcion- mimicin...