ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::SpectralBloomFilter< T, C, H > Class Template Reference

a filter of Bloom of \( m \) counters of the type C and \( r \) hashes, for multisets More...

#include <ADS/set/BloomVariants.h>

Public member functions

 SpectralBloomFilter (void)
 a filter of 64 counters and one hash, empty
 SpectralBloomFilter (std::size_t m, int r, H h=H())
 the empty filter of \( m \) counters and \( r \) hashes
void insert (const T &x, C f=1)
 \( f \) added to the multiplicity of \( x \)
void remove (const T &x, C f=1)
 \( f \) subtracted from the multiplicity of \( x \); a stuck counter stays
C count (const T &x) const
 the least counter of \( x \) (the minimum selection), never below its multiplicity
bool maybe (const T &x) const
 whether \( x \) may be there, count( x ) \( > 0 \): false only if \( x \) is not there
std::size_t stuck (void) const
 the counters at their largest value, which no longer move
std::size_t counters (void) const
 the counters \( m \)
int hashes (void) const
 the hashes \( r \)
template<class A>
void persist (A &a)
 the members written to, or read from, the archive \( a \) [see Persistence.h]

Static public member functions

static constexpr std::uint64_t persistTag (void)
 the parameters of the layout, in a file

Static public attributes

static constexpr std::string_view persistName = "SpectralBloomFilter"
 the name of the structure in a file [see Persistence.h]

Detailed description

template<class T, class C = std::uint32_t, class H = std::hash< T >>
class ADS::SpectralBloomFilter< T, C, H >

a filter of Bloom of \( m \) counters of the type C and \( r \) hashes, for multisets

Constructor and destructor documentation

◆ SpectralBloomFilter() [1/2]

template<class T, class C = std::uint32_t, class H = std::hash< T >>
ADS::SpectralBloomFilter< T, C, H >::SpectralBloomFilter ( void )
inline

a filter of 64 counters and one hash, empty

◆ SpectralBloomFilter() [2/2]

template<class T, class C = std::uint32_t, class H = std::hash< T >>
ADS::SpectralBloomFilter< T, C, H >::SpectralBloomFilter ( std::size_t m,
int r,
H h = H() )

the empty filter of \( m \) counters and \( r \) hashes

Precondition
\( m \ge 1 \) and \( r \ge 1 \)

Member function documentation

◆ count()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
C ADS::SpectralBloomFilter< T, C, H >::count ( const T & x) const
nodiscard

the least counter of \( x \) (the minimum selection), never below its multiplicity

In pseudocode (Cohen and Matias):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{count}( x ) \cr 2 & \quad \textbf{return}\ \min\{ C[ j ] : j \text{ among the } r \text{ places of } x \} \end{array}} \]

◆ counters()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
std::size_t ADS::SpectralBloomFilter< T, C, H >::counters ( void ) const
nodiscard

the counters \( m \)

◆ hashes()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
int ADS::SpectralBloomFilter< T, C, H >::hashes ( void ) const
nodiscard

the hashes \( r \)

◆ insert()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
void ADS::SpectralBloomFilter< T, C, H >::insert ( const T & x,
C f = 1 )

\( f \) added to the multiplicity of \( x \)

In pseudocode (Cohen and Matias), \( C \) the counters and \( \mathit{top} \) the largest value of a counter, at which it sticks:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{insert}( x , f ) \cr 2 & \quad \textbf{foreach}\ j\ \text{among the } r \text{ places of } x\ \textbf{do} \cr 3 & \qquad C[ j ] \gets \min( C[ j ] + f , \mathit{top} ) \end{array}} \]

Postcondition
count( x ) \( \ge f \), and maybe( x ) if \( f > 0 \)

◆ maybe()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
bool ADS::SpectralBloomFilter< T, C, H >::maybe ( const T & x) const
nodiscard

whether \( x \) may be there, count( x ) \( > 0 \): false only if \( x \) is not there

◆ persist()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
template<class A>
void ADS::SpectralBloomFilter< T, C, H >::persist ( A & a)

the members written to, or read from, the archive \( a \) [see Persistence.h]

◆ persistTag()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
constexpr std::uint64_t ADS::SpectralBloomFilter< T, C, H >::persistTag ( void )
inlinestaticnodiscardconstexpr

the parameters of the layout, in a file

◆ remove()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
void ADS::SpectralBloomFilter< T, C, H >::remove ( const T & x,
C f = 1 )

\( f \) subtracted from the multiplicity of \( x \); a stuck counter stays

In pseudocode (Cohen and Matias, Fan et al.):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{remove}( x , f ) \cr 2 & \quad \textbf{foreach}\ j\ \text{among the } r \text{ places of } x\ \textbf{with}\ C[ j ] \ne \mathit{top}\ \textbf{do}\ C[ j ] \gets C[ j ] - f \end{array}} \]

Precondition
count( x ) \( \ge f \)

◆ stuck()

template<class T, class C = std::uint32_t, class H = std::hash< T >>
std::size_t ADS::SpectralBloomFilter< T, C, H >::stuck ( void ) const
nodiscard

the counters at their largest value, which no longer move

Member data documentation

◆ persistName

template<class T, class C = std::uint32_t, class H = std::hash< T >>
std::string_view ADS::SpectralBloomFilter< T, C, H >::persistName = "SpectralBloomFilter"
staticconstexpr

the name of the structure in a file [see Persistence.h]


The documentation for this class was generated from the following file: