ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::PermutedBuckets Class Reference

a set of values below \( 2^w \), permuted by \( x \mapsto ( a x + c ) \bmod 2^w \) and split by the top bits of the images into buckets of \( L \) items on average More...

#include <ADS/set/SortedIntersection.h>

Public member functions

 PermutedBuckets (const std::vector< std::uint64_t > &A, unsigned w, std::size_t L, std::uint64_t a, std::uint64_t c)
 the values of \( A \), distinct, in any order
std::size_t size (void) const
 the items
std::size_t buckets (void) const
 the buckets, \( 2^\ell \)
std::vector< std::uint64_t > intersect (const PermutedBuckets &other, std::size_t *scanned=nullptr) const
 the values common to the two sets, sorted; the items of the two sets looked at go to *scanned, if given
std::vector< std::uint64_t > values (void) const
 the values of the set, sorted, by inverting the permutation

Detailed description

a set of values below \( 2^w \), permuted by \( x \mapsto ( a x + c ) \bmod 2^w \) and split by the top bits of the images into buckets of \( L \) items on average

Constructor and destructor documentation

◆ PermutedBuckets()

ADS::PermutedBuckets::PermutedBuckets ( const std::vector< std::uint64_t > & A,
unsigned w,
std::size_t L,
std::uint64_t a,
std::uint64_t c )

the values of \( A \), distinct, in any order

In pseudocode (Sanders and Transier, and Ferragina, chapter 6):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{build}( A , w , L , a , c ) \cr 2 & \quad \ell \gets \text{the least } \ell \le w \text{ with } 2^\ell L \ge | A | \cr 3 & \quad I \gets ( ( a x + c ) \bmod 2^w : x \in A ) \text{, sorted} \cr 4 & \quad \mathit{off}[ g ] \gets \text{the first place of } I \text{ whose top } \ell \text{ bits are } g \text{, by counting} \end{array}} \]

Precondition
\( 1 \le w \le 63 \), \( a \) odd, \( L \ge 1 \), the values of \( A \) distinct and below \( 2^w \)

Member function documentation

◆ buckets()

std::size_t ADS::PermutedBuckets::buckets ( void ) const
nodiscard

the buckets, \( 2^\ell \)

◆ intersect()

std::vector< std::uint64_t > ADS::PermutedBuckets::intersect ( const PermutedBuckets & other,
std::size_t * scanned = nullptr ) const
nodiscard

the values common to the two sets, sorted; the items of the two sets looked at go to *scanned, if given

In pseudocode (Sanders and Transier, and Ferragina, chapter 6), \( S \) the smaller set and \( G \) the larger, \( j \) only going forward in the images of \( G \):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{intersect}( S , G ) \cr 2 & \quad j \gets 0;\ C \gets ( ) \cr 3 & \quad \textbf{foreach}\ \text{image } y \text{ of } S \text{, in } \text{increasing order}\ \textbf{do} \cr 4 & \qquad g \gets \text{the top } \ell \text{ bits of } y \text{ in } G; \ j \gets \max( j , G.\mathit{off}[ g ] ) \cr 5 & \qquad \textbf{while}\ j < G.\mathit{off}[ g + 1 ]\ \textbf{and} \ G.I[ j ] < y\ \textbf{do}\ j \gets j + 1 \cr 6 & \qquad \textbf{if}\ j < G.\mathit{off}[ g + 1 ]\ \textbf{and} \ G.I[ j ] = y\ \textbf{then}\ \text{append } \pi^{-1}( y ) \text{ to } C;\ j \gets j + 1 \cr 7 & \quad \textbf{return}\ C \text{, sorted} \end{array}} \]

Precondition
the same \( w \), \( a \) and \( c \)
Postcondition
the intersection of the two sets (an audit)

◆ size()

std::size_t ADS::PermutedBuckets::size ( void ) const
nodiscard

the items

◆ values()

std::vector< std::uint64_t > ADS::PermutedBuckets::values ( void ) const
nodiscard

the values of the set, sorted, by inverting the permutation


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