|
ADS
Algorithms and Data Structures
|
a static sequence of integers of variable length with direct access More...
#include <ADS/compression/DirectAccessCodes.h>
Public types | |
| enum class | Levels : int { UNCAPPED = 0 , DEFAULT = 3 } |
| the most levels of the widths that minimize the bits: a number \( h \ge 1 \), or no bound More... | |
| using | value_type = std::uint64_t |
| the type of the items | |
| using | size_type = std::size_t |
| the type of the sizes | |
| using | difference_type = std::ptrdiff_t |
| the type of the distances | |
| using | reference = std::uint64_t |
| an item, by value | |
| using | const_reference = std::uint64_t |
| an item, by value | |
| using | const_iterator = SubscriptIterator< DirectAccessCodes , std::uint64_t > |
| the iterator, by access() | |
| using | iterator = const_iterator |
| the same as const_iterator | |
Public member functions | |
| DirectAccessCodes (void)=default | |
| the empty sequence | |
| DirectAccessCodes (std::span< const std::uint64_t > x, Levels L=Levels::DEFAULT) | |
| the sequence \( x \), with the widths of at most \( h \) levels (\( h \) the value of \( L \), or \( w \) if UNCAPPED) that minimize its bits | |
| DirectAccessCodes (std::span< const std::uint64_t > x, int b) | |
| the sequence \( x \), with levels of \( b \) bits each (the last one up to the bits of the largest item), which trades bits for fewer levels: the levels of build() above with \( \mathit{cut}[ s ] = \min( w , s + b ) \) | |
| std::size_t | size (void) const |
| the number \( n \) of the items | |
| bool | empty (void) const |
| whether there is no item | |
| std::uint64_t | access (std::size_t i) const |
| the item \( x_i \) | |
| std::uint64_t | operator[] (std::size_t i) const |
| the item \( x_i \), by access() | |
| std::vector< int > | widths (void) const |
| the widths of the chunks of the levels | |
| std::size_t | sizeInBits (void) const |
| the bits of the chunks, of the continuation bits and of their ranks | |
| const_iterator | begin (void) const |
| the iterator at 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() | |
a static sequence of integers of variable length with direct access
| using ADS::DirectAccessCodes::const_iterator = SubscriptIterator< DirectAccessCodes , std::uint64_t > |
the iterator, by access()
| using ADS::DirectAccessCodes::const_reference = std::uint64_t |
an item, by value
| using ADS::DirectAccessCodes::difference_type = std::ptrdiff_t |
the type of the distances
the same as const_iterator
| using ADS::DirectAccessCodes::reference = std::uint64_t |
an item, by value
| using ADS::DirectAccessCodes::size_type = std::size_t |
the type of the sizes
| using ADS::DirectAccessCodes::value_type = std::uint64_t |
the type of the items
|
strong |
|
default |
the empty sequence
|
explicit |
the sequence \( x \), with the widths of at most \( h \) levels (\( h \) the value of \( L \), or \( w \) if UNCAPPED) that minimize its bits
In pseudocode (the dynamic program of Brisaboa, Ladra and Navarro, beyond the book), \( n_s \) the integers of more than \( s \) bits (\( n_0 = n \)) and \( w \) the bits of the largest one:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{DirectAccessCodes}( x , h ) \cr 2 & \quad \textbf{for}\ l \gets 1\ \textbf{to}\ h ,\ s \gets w - 1 \ \textbf{downto}\ 0\ \textbf{do} \cr 3 & \qquad \mathit{at}[ l , s ] \gets \text{the } t \in ( s , w ] \text{ of least } n_s ( t - s ) + [ t < w ] ( 1.25 \, n_s + C[ l - 1 , t ] ) \text{, } t = w \text{ if } l = 1 \cr 4 & \qquad C[ l , s ] \gets \text{that least cost} \cr 5 & \quad s \gets 0 ;\ \textbf{for}\ l \gets h\ \textbf{downto}\ 1 \ \textbf{while}\ s < w\ \textbf{do}\ \mathit{cut}[ s ] \gets \mathit{at}[ l , s ] ;\ s \gets \mathit{cut}[ s ] \cr 6 & \quad \mathrm{build}( x , \mathit{cut} ) \cr 7 & \textbf{procedure}\ \mathrm{build}( x , \mathit{cut} ) \cr 8 & \quad s \gets 0;\ y \gets x \cr 9 & \quad \textbf{while}\ s < w\ \textbf{do} \cr 10 & \qquad b \gets \mathit{cut}[ s ] - s;\ A \gets \text{the bits } [ s , s + b ) \text{ of each item of } y \cr 11 & \qquad \textbf{if}\ \mathit{cut}[ s ] < w\ \textbf{then}\ B \gets ( [ y_j \ge 2^{s + b} ] )_j \text{ with rank};\ y \gets \text{the } y_j \text{ with } y_j \ge 2^{s + b} \cr 12 & \qquad \text{add the level } ( A , B );\ s \gets \mathit{cut}[ s ] \end{array}} \]
| ADS::DirectAccessCodes::DirectAccessCodes | ( | std::span< const std::uint64_t > | x, |
| int | b ) |
the sequence \( x \), with levels of \( b \) bits each (the last one up to the bits of the largest item), which trades bits for fewer levels: the levels of build() above with \( \mathit{cut}[ s ] = \min( w , s + b ) \)
|
nodiscard |
the item \( x_i \)
In pseudocode (Brisaboa, Ladra and Navarro, beyond the book), the levels \( ( A_\ell , B_\ell ) \) from the first:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{access}( i ) \cr 2 & \quad v \gets 0;\ \ell \gets 0 \cr 3 & \quad \textbf{loop} \cr 4 & \qquad v \gets v + A_\ell[ i ] \cdot 2^{s_\ell} \cr 5 & \qquad \textbf{if}\ \ell \text{ is the last level}\ \textbf{or} \ B_\ell[ i ] = 0\ \textbf{then return}\ v \cr 6 & \qquad i \gets \mathrm{rank}_1( B_\ell , i );\ \ell \gets \ell + 1 \end{array}} \]
|
inlinenodiscard |
the iterator at the first item
|
inlinenodiscard |
the same as begin()
|
inlinenodiscard |
the same as end()
|
inlinenodiscard |
whether there is no item
|
inlinenodiscard |
the iterator past the last item
|
inlinenodiscard |
the item \( x_i \), by access()
|
inlinenodiscard |
the number \( n \) of the items
|
nodiscard |
the bits of the chunks, of the continuation bits and of their ranks
|
nodiscard |
the widths of the chunks of the levels