|
ADS
Algorithms and Data Structures
|
The Elias-Fano representation of a non-decreasing sequence \( x_0 \le \cdots \le x_{n-1} \) of integers in \( [ 0 , u ) \) (chapters 11, Integer Coding, and 15, Compressed Data Structures, of Ferragina's book): each item is split into its \( \ell = \lceil \log_2( u / n ) \rceil \) low bits, written one after the other in \( L \), and its high bits, the bucket \( x_i \gg \ell \), written in \( H \) as the unary counts of the buckets (\( 1^c 0 \) for a bucket of \( c \) items), so that the \( i \)-th 1 of \( H \) is at the place \( ( x_i \gg \ell ) + i \). More...
#include "ADS/Contract.h"#include "ADS/combinatorial/Bitwise.h"#include "ADS/succinct/BitVector.h"#include "ADS/succinct/RankSelect.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <string_view>#include <vector>#include "ADS/succinct/impl/EliasFano.tpp"Go to the source code of this file.
Classes | |
| 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] More... | |
Namespaces | |
| namespace | ADS |
Typedefs | |
| using | ADS::EliasFano = BasicEliasFano< false > |
| Elias-Fano with the inventories of \( H \) built in the constructor, the fastest access() and nextGEQ(). | |
| using | ADS::LazyEliasFano = BasicEliasFano< true > |
| Elias-Fano with the inventories of \( H \) built at the first query that needs them, the fastest construction. | |
The Elias-Fano representation of a non-decreasing sequence \( x_0 \le \cdots \le x_{n-1} \) of integers in \( [ 0 , u ) \) (chapters 11, Integer Coding, and 15, Compressed Data Structures, of Ferragina's book): each item is split into its \( \ell = \lceil \log_2( u / n ) \rceil \) low bits, written one after the other in \( L \), and its high bits, the bucket \( x_i \gg \ell \), written in \( H \) as the unary counts of the buckets (\( 1^c 0 \) for a bucket of \( c \) items), so that the \( i \)-th 1 of \( H \) is at the place \( ( x_i \gg \ell ) + i \).
\( H \) has \( n \) 1s and at most \( n \) 0s, since \( 2^\ell \ge u / n \), and the sequence takes at most \( 2 n + n \lceil \log_2( u / n ) \rceil \) bits whatever its distribution, within 2 bits per item of the \( \log_2 \binom{u}{n} \) bits needed to tell \( n \) items of \( [ 0 , u ) \) apart.
With rank and select on \( H \) [see RankSelect.h] the sequence is not only decoded but searched in place:
Ferragina's book computes the rank of \( B \) by a binary search on the select, in \( O( \log n ) \) time; the bucket found by \( \mathrm{select}_0 \) makes it \( O( 1 ) \) expected, the design of the quasi-succinct indices of Vigna and of the sdarray of Okanohara and Sadakane. \( H \) is written with the 1s for the items and the 0s for the buckets, as in its chapter 11 (its chapter 15 swaps them, which only swaps \( \mathrm{select}_0 \) and \( \mathrm{select}_1 \)). The representation ignores the regularities of the sequence: the partitioned Elias-Fano of Ottaviano and Venturini [see PartitionedEliasFano.h] splits it into chunks, each one coded at its own best, and comes within a few percent of the interpolative code [see IntegerCodes.h] keeping the random access.
The contracts [see Contract.h]: the sequence is non-decreasing (an audit) and below \( u \), and access() needs \( i < n \); the audit of the construction is that access() gives back each item, and the postcondition of nextGEQ() is that the items before the place are \( < x \) and the one at it is not. The functions are defined in EliasFano.tpp.