ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::BasicEliasFano< Lazy > Class Template Reference

a non-decreasing sequence of integers in the Elias-Fano representation, the inventories of select of \( H \) built in the constructor if not Lazy and at the first select of each value if Lazy [see RankSelect.h] More...

#include <ADS/succinct/EliasFano.h>

Public types

using value_type = std::uint64_t
 the type of an item
using size_type = std::size_t
 the type of a size
using difference_type = std::ptrdiff_t
 the type of the distance of two places
using reference = std::uint64_t
 an item, returned by value
using const_reference = std::uint64_t
 an item, returned by value
using const_iterator = SubscriptIterator< BasicEliasFano , std::uint64_t >
 the constant iterator, random access
using iterator = const_iterator
 the same as const_iterator

Public member functions

 BasicEliasFano (void)=default
 the empty sequence
 BasicEliasFano (const std::vector< std::uint64_t > &x)
 the sequence \( x \) in the universe \( [ 0 , x_{n-1} + 1 ) \)
 BasicEliasFano (const std::vector< std::uint64_t > &x, std::uint64_t u)
 the sequence \( x \) in the universe \( [ 0 , u ) \)
std::size_t size (void) const
 the number of items, \( n \)
bool empty (void) const
 whether there is no item
std::uint64_t universe (void) const
 the bound \( u \) of the items
std::uint64_t access (std::size_t i) const
 the item \( i \)
std::uint64_t operator[] (std::size_t i) const
 the item \( i \), as access()
std::size_t nextGEQ (std::uint64_t x) const
 the place of the first item \( \ge x \), size() if there is none, i.e., the number of items \( < x \)
bool contains (std::uint64_t x) const
 whether \( x \) is an item, by nextGEQ()
int lowWidth (void) const
 the number of low bits of each item, \( \ell \)
const BitVector & low (void) const
 the low bits, \( L \)
const BasicRankSelect< Lazy > & high (void) const
 the high bits, \( H \), with their directory
std::size_t codeBits (void) const
 the bits of \( L \) and \( H \), without the directory of \( H \)
std::size_t sizeInBits (void) const
 all the bits, with the directory of H
std::vector< std::uint64_t > decode (void) const
 the items, decoded in \( O( n ) \) time
template<class A>
void persist (A &a)
 the members written to, or read from, the archive \( a \) [see Persistence.h]
const_iterator begin (void) const
 the iterator on the first item
const_iterator end (void) const
 the iterator past the last item
const_iterator cbegin (void) const
 the same as begin()
const_iterator cend (void) const
 the same as end()

Static public attributes

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

Detailed description

template<bool Lazy>
class ADS::BasicEliasFano< Lazy >

a non-decreasing sequence of integers in the Elias-Fano representation, the inventories of select of \( H \) built in the constructor if not Lazy and at the first select of each value if Lazy [see RankSelect.h]

Member typedef documentation

◆ const_iterator

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::const_iterator = SubscriptIterator< BasicEliasFano , std::uint64_t >

the constant iterator, random access

◆ const_reference

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::const_reference = std::uint64_t

an item, returned by value

◆ difference_type

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::difference_type = std::ptrdiff_t

the type of the distance of two places

◆ iterator

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::iterator = const_iterator

the same as const_iterator

◆ reference

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::reference = std::uint64_t

an item, returned by value

◆ size_type

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::size_type = std::size_t

the type of a size

◆ value_type

template<bool Lazy>
using ADS::BasicEliasFano< Lazy >::value_type = std::uint64_t

the type of an item

Constructor and destructor documentation

◆ BasicEliasFano() [1/3]

template<bool Lazy>
ADS::BasicEliasFano< Lazy >::BasicEliasFano ( void )
default

the empty sequence

◆ BasicEliasFano() [2/3]

template<bool Lazy>
ADS::BasicEliasFano< Lazy >::BasicEliasFano ( const std::vector< std::uint64_t > & x)
explicit

the sequence \( x \) in the universe \( [ 0 , x_{n-1} + 1 ) \)

Precondition
\( x \) is non-decreasing (an audit) and \( x_{n-1} < 2^{64} - 1 \), so that the universe fits in 64 bits

◆ BasicEliasFano() [3/3]

template<bool Lazy>
ADS::BasicEliasFano< Lazy >::BasicEliasFano ( const std::vector< std::uint64_t > & x,
std::uint64_t u )

the sequence \( x \) in the universe \( [ 0 , u ) \)

In pseudocode (chapter 11, Integer Coding, of Ferragina's book, beyond the book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{build}( x , u ) \cr 2 & \quad \ell \gets \lceil \log_2( u / n ) \rceil\ \text{(0 if } u \le n \text{)} \cr 3 & \quad H \gets n + \lfloor ( u - 1 ) / 2^\ell \rfloor + 1 \text{ bits } \text{equal to 0};\ L \gets \text{an empty vector of bits} \cr 4 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do} \cr 5 & \qquad \mathrm{append}( L , x_i \bmod 2^\ell , \ell ) \cr 6 & \qquad H[ \lfloor x_i / 2^\ell \rfloor + i ] \gets 1 \cr 7 & \quad \text{build the directory of rank and select of } H \end{array}} \]

Precondition
\( x \) is non-decreasing (an audit) and its items are below \( u \)

Member function documentation

◆ access()

template<bool Lazy>
std::uint64_t ADS::BasicEliasFano< Lazy >::access ( std::size_t i) const
nodiscard

the item \( i \)

In pseudocode (chapter 11, Integer Coding, of Ferragina's book, beyond the book):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{access}( i ) \cr 2 & \quad h \gets \mathrm{select}_1( H , i + 1 ) - i\quad \triangleright\ \text{the bucket of } x_i \cr 3 & \quad \textbf{return}\ h \cdot 2^\ell + L[ i \ell .. ( i + 1 ) \ell - 1 ] \end{array}} \]

Precondition
\( i < \) size()

◆ begin()

template<bool Lazy>
const_iterator ADS::BasicEliasFano< Lazy >::begin ( void ) const
inlinenodiscard

the iterator on the first item

◆ cbegin()

template<bool Lazy>
const_iterator ADS::BasicEliasFano< Lazy >::cbegin ( void ) const
inlinenodiscard

the same as begin()

◆ cend()

template<bool Lazy>
const_iterator ADS::BasicEliasFano< Lazy >::cend ( void ) const
inlinenodiscard

the same as end()

◆ codeBits()

template<bool Lazy>
std::size_t ADS::BasicEliasFano< Lazy >::codeBits ( void ) const
nodiscard

the bits of \( L \) and \( H \), without the directory of \( H \)

◆ contains()

template<bool Lazy>
bool ADS::BasicEliasFano< Lazy >::contains ( std::uint64_t x) const
nodiscard

whether \( x \) is an item, by nextGEQ()

◆ decode()

template<bool Lazy>
std::vector< std::uint64_t > ADS::BasicEliasFano< Lazy >::decode ( void ) const
nodiscard

the items, decoded in \( O( n ) \) time

◆ empty()

template<bool Lazy>
bool ADS::BasicEliasFano< Lazy >::empty ( void ) const
nodiscard

whether there is no item

◆ end()

template<bool Lazy>
const_iterator ADS::BasicEliasFano< Lazy >::end ( void ) const
inlinenodiscard

the iterator past the last item

◆ high()

template<bool Lazy>
const BasicRankSelect< Lazy > & ADS::BasicEliasFano< Lazy >::high ( void ) const
nodiscard

the high bits, \( H \), with their directory

◆ low()

template<bool Lazy>
const BitVector & ADS::BasicEliasFano< Lazy >::low ( void ) const
nodiscard

the low bits, \( L \)

◆ lowWidth()

template<bool Lazy>
int ADS::BasicEliasFano< Lazy >::lowWidth ( void ) const
nodiscard

the number of low bits of each item, \( \ell \)

◆ nextGEQ()

template<bool Lazy>
std::size_t ADS::BasicEliasFano< Lazy >::nextGEQ ( std::uint64_t x) const
nodiscard

the place of the first item \( \ge x \), size() if there is none, i.e., the number of items \( < x \)

In pseudocode (Vigna and Okanohara and Sadakane, beyond the book), \( \mathit{low}( i ) \) the low bits of the item \( i \):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{nextGEQ}( x ) \cr 2 & \quad \textbf{if}\ n = 0\ \textbf{or}\ x \ge u\ \textbf{then return} \ n \cr 3 & \quad h \gets \lfloor x / 2^\ell \rfloor;\ \mathit{pos} \gets 0 \ \text{if } h = 0 \text{, else } \mathrm{select}_0( H , h ) + 1 \cr 4 & \quad p \gets \mathit{pos} - h\quad \triangleright\ \text{the first } \text{item of the bucket } h \cr 5 & \quad \textbf{while}\ H[ \mathit{pos} ] = 1\ \textbf{and} \ \mathit{low}( p ) < x \bmod 2^\ell\ \textbf{do} \cr 6 & \qquad p \gets p + 1;\ \mathit{pos} \gets \mathit{pos} + 1\quad \triangleright\ \text{past 8 items, a binary search} \cr 7 & \quad \textbf{return}\ p \end{array}} \]

Postcondition
the items before it are \( < x \), the one at it is \( \ge x \)

◆ operator[]()

template<bool Lazy>
std::uint64_t ADS::BasicEliasFano< Lazy >::operator[] ( std::size_t i) const
nodiscard

the item \( i \), as access()

Precondition
\( i < \) size()

◆ persist()

template<bool Lazy>
template<class A>
void ADS::BasicEliasFano< Lazy >::persist ( A & a)

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

◆ size()

template<bool Lazy>
std::size_t ADS::BasicEliasFano< Lazy >::size ( void ) const
nodiscard

the number of items, \( n \)

◆ sizeInBits()

template<bool Lazy>
std::size_t ADS::BasicEliasFano< Lazy >::sizeInBits ( void ) const
nodiscard

all the bits, with the directory of H

◆ universe()

template<bool Lazy>
std::uint64_t ADS::BasicEliasFano< Lazy >::universe ( void ) const
nodiscard

the bound \( u \) of the items

Member data documentation

◆ persistName

template<bool Lazy>
std::string_view ADS::BasicEliasFano< Lazy >::persistName
staticconstexpr
Initial value:
=
Lazy ? "LazyEliasFano" : "EliasFano"

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


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