|
ADS
Algorithms and Data Structures
|
The compressed vector of bits of Raman, Raman and Rao (RRR), in the practical form of Claude and Navarro: a static vector \( B \) of \( m \) bits with \( n \) 1s in at most \( m H_0( B ) + 0.175 m \) bits, i.e., below \( m \) when the 1s (or the 0s) are rare, with access, rank and select. More...
#include "ADS/Contract.h"#include "ADS/external/MappedFile.h"#include "ADS/succinct/BitVector.h"#include <array>#include <bit>#include <cstddef>#include <cstdint>#include <string_view>#include <vector>#include "ADS/succinct/impl/RRRBitVector.tpp"Go to the source code of this file.
Classes | |
| class | ADS::RRRBitVector |
| a static vector of bits compressed to its entropy, with rank and select More... | |
Namespaces | |
| namespace | ADS |
The compressed vector of bits of Raman, Raman and Rao (RRR), in the practical form of Claude and Navarro: a static vector \( B \) of \( m \) bits with \( n \) 1s in at most \( m H_0( B ) + 0.175 m \) bits, i.e., below \( m \) when the 1s (or the 0s) are rare, with access, rank and select.
\( B \) is cut in blocks of \( b = 63 \) bits; a block of \( c \) 1s is written as its class \( c \), in 6 bits, and as its offset, its place among the \( \binom{b}{c} \) blocks of class \( c \), in \( \lceil \log_2 \binom{b}{c} \rceil \) bits. The offset of the block with its 1s at the places \( p_1 < \cdots < p_c \) is its rank in the colexicographic order,
\[ o = \sum_{t=1}^{c} \binom{p_t}{t} , \]
the combinatorial number system, and the block is rebuilt from \( o \) from its highest place down: the place \( p \) holds the \( t \)-th 1 from the lowest, \( t \) the 1s not yet met, if and only if \( \binom{p}{t} \le o \), which is then taken away from \( o \). A query walks only the places it needs: the rank stops at its place or at the last 1, the select at its bit. Since \( \sum_j \log_2 \binom{b}{c_j} \le \log_2 \binom{m}{n} \le m H_0( B ) \) (the product of the binomials of the blocks counts a part of the vectors of \( n \) 1s), the offsets take at most \( m H_0( B ) + m / b \) bits, the rounding up costing a bit per block, and the classes \( 6 m / b \); a superblock of 32 blocks (2016 bits) keeps the 1s before it and the place of its first offset, at most \( 128 / 2016 = 6.3 \% \) of \( m \), in all \( m H_0( B ) + ( 7 / 63 + 128 / 2016 ) m < m H_0( B ) + 0.175 m \) bits. Hence:
The contracts [see Contract.h]: the places and the ranks are in range as for RankSelect [see RankSelect.h]; the audit of the construction is that the vector gives back each bit. The functions are defined in RRRBitVector.tpp.