|
ADS
Algorithms and Data Structures
|
a stream of bits written at its end, on a BitVector More...
#include <ADS/succinct/BitStream.h>
Public member functions | |
| BitWriter (void)=default | |
| an empty stream | |
| std::size_t | size (void) const |
| the bits written so far | |
| void | writeBit (bool b) |
| appends the bit \( b \) | |
| void | write (Word v, int len) |
| the \( \mathit{len} \) bits of \( v \), the least significant first | |
| void | writeBinary (Word v, int len) |
| the \( \mathit{len} \) bits of \( v \), the most significant first | |
| void | writeUnary (std::uint64_t q) |
| \( q \) zeros and a 1, the unary code \( U( q + 1 ) \) | |
| const BitVector & | bits (void) const |
| the bits written | |
| BitVector | release (void) |
| the bits written, which the writer leaves empty | |
a stream of bits written at its end, on a BitVector
|
default |
an empty stream
|
nodiscard |
the bits written
|
nodiscard |
the bits written, which the writer leaves empty
|
nodiscard |
the bits written so far
| void ADS::BitWriter::write | ( | Word | v, |
| int | len ) |
the \( \mathit{len} \) bits of \( v \), the least significant first
| void ADS::BitWriter::writeBinary | ( | Word | v, |
| int | len ) |
the \( \mathit{len} \) bits of \( v \), the most significant first
In pseudocode (the binary code of chapter 11, Integer Coding, of Ferragina's book, beyond the book), the field turned around and appended as write() does:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{writeBinary}( v , \mathit{len} ) \cr 2 & \quad r \gets \text{the } \mathit{len} \text{ low bits of } v \text{ in the reverse order} \cr 3 & \quad \mathrm{write}( r , \mathit{len} ) \end{array}} \]
| void ADS::BitWriter::writeBit | ( | bool | b | ) |
appends the bit \( b \)
| void ADS::BitWriter::writeUnary | ( | std::uint64_t | q | ) |
\( q \) zeros and a 1, the unary code \( U( q + 1 ) \)
In pseudocode (the unary code of chapter 11, Integer Coding, of Ferragina's book, beyond the book), whole words of zeros first:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{writeUnary}( q ) \cr 2 & \quad \textbf{while}\ q \ge 64\ \textbf{do}\ \mathrm{write}( 0 , 64 );\ q \gets q - 64 \cr 3 & \quad \mathrm{write}( 2^q , q + 1 )\quad \triangleright\ q \ \text{zeros, then a 1} \end{array}} \]