ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches

The vector of bits on which the succinct structures and the integer codes of ADS are built. More...

Files

file  ADS/succinct/BitVector.h
 The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits are packed in words of 64 bits, the bit \( i \) being the bit \( i \bmod 64 \) (from the least significant one) of the word \( \lfloor i / 64 \rfloor \), so that a field of up to 64 bits is read or written with two shifts at most.

Classes

class  ADS::SubscriptIterator< O, T >
 the random-access constant iterator on the items T of the owner O, read by ( *o )[ i ] More...
class  ADS::BitVector
 a vector of bits packed in words of 64 bits More...

Typedefs

using ADS::Words = std::vector< Word , detail::LineAllocator< Word > >
 the words of a BitVector, on lines of the cache

Functions

constexpr int ADS::selectInWord (Word x, int k)
 the place of the \( k \)-th 1 of the word \( x \), counting \( k \) from 0 and the places from the least significant bit

Detailed description

The vector of bits on which the succinct structures and the integer codes of ADS are built.

The definitions, the invariants and the costs of the area are in Theory of succinct structures.

Typedef documentation

◆ Words

using ADS::Words = std::vector< Word , detail::LineAllocator< Word > >

the words of a BitVector, on lines of the cache

Function documentation

◆ selectInWord()

int ADS::selectInWord ( Word x,
int k )
nodiscardconstexpr

the place of the \( k \)-th 1 of the word \( x \), counting \( k \) from 0 and the places from the least significant bit

In pseudocode (the broadword select of Vigna, beyond the book), with \( L_8 = \sum_{j < 8} 2^{8 j} \), \( H_8 = 2^7 L_8 \) and \( \mathrm{ctz} \) the trailing zeros of a word:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{selectInWord}( x , k ) \cr 2 & \quad s \gets \text{the sideways sums of the bytes of } x \cr 3 & \quad s \gets s \cdot L_8\quad \triangleright\ \text{the byte } j \text{ of } s \text{ counts the 1s of the bytes } 0 , \ldots , j \cr 4 & \quad b \gets \lfloor \mathrm{ctz}( ( s + ( 127 - k ) L_8 ) \wedge H_8 ) / 8 \rfloor\quad \triangleright\ \text{the first byte past } k \cr 5 & \quad r \gets k - \text{the byte } b - 1 \text{ of } s \ \text{(0 if } b = 0 \text{)} \cr 6 & \quad v \gets \text{the byte } b \text{ of } x \cr 7 & \quad \textbf{return}\ 8 b + T[ 8 v + r ]\quad \triangleright \ T \text{ the places of the 1s of each byte by rank} \end{array}} \]

With ADS_WITH_HIGHWAY, on a target whose compress of 64 bytes is one instruction (AVX-512 VBMI2), and out of a constant expression, the place is instead the byte \( k \) of the bytes \( 0 , \ldots , 63 \) compressed by the bits of \( x \) [see select() of FastBitwise.h]

Precondition
\( k < \) sidewaysSum( x )