ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::DirectAccessCodes Class Reference

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()

Detailed description

a static sequence of integers of variable length with direct access

Member typedef documentation

◆ const_iterator

◆ const_reference

an item, by value

◆ difference_type

the type of the distances

◆ iterator

◆ reference

using ADS::DirectAccessCodes::reference = std::uint64_t

an item, by value

◆ size_type

using ADS::DirectAccessCodes::size_type = std::size_t

the type of the sizes

◆ value_type

using ADS::DirectAccessCodes::value_type = std::uint64_t

the type of the items

Member enumeration documentation

◆ Levels

enum class ADS::DirectAccessCodes::Levels : int
strong

the most levels of the widths that minimize the bits: a number \( h \ge 1 \), or no bound

Enumerator
UNCAPPED 

as many levels as minimize the bits

DEFAULT 

at most 3 levels

Constructor and destructor documentation

◆ DirectAccessCodes() [1/3]

ADS::DirectAccessCodes::DirectAccessCodes ( void )
default

the empty sequence

◆ DirectAccessCodes() [2/3]

ADS::DirectAccessCodes::DirectAccessCodes ( std::span< const std::uint64_t > x,
Levels L = Levels::DEFAULT )
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}} \]

Precondition
\( L \) is UNCAPPED or \( h \ge 1 \)
Postcondition
access() gives each item of \( x \) back (audit)

◆ DirectAccessCodes() [3/3]

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 ) \)

Precondition
\( 1 \le b \le 64 \)
Postcondition
access() gives each item of \( x \) back (audit)

Member function documentation

◆ access()

std::uint64_t ADS::DirectAccessCodes::access ( std::size_t i) const
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}} \]

Precondition
\( i < \) size()

◆ begin()

const_iterator ADS::DirectAccessCodes::begin ( void ) const
inlinenodiscard

the iterator at the first item

◆ cbegin()

const_iterator ADS::DirectAccessCodes::cbegin ( void ) const
inlinenodiscard

the same as begin()

◆ cend()

const_iterator ADS::DirectAccessCodes::cend ( void ) const
inlinenodiscard

the same as end()

◆ empty()

bool ADS::DirectAccessCodes::empty ( void ) const
inlinenodiscard

whether there is no item

◆ end()

const_iterator ADS::DirectAccessCodes::end ( void ) const
inlinenodiscard

the iterator past the last item

◆ operator[]()

std::uint64_t ADS::DirectAccessCodes::operator[] ( std::size_t i) const
inlinenodiscard

the item \( x_i \), by access()

◆ size()

std::size_t ADS::DirectAccessCodes::size ( void ) const
inlinenodiscard

the number \( n \) of the items

◆ sizeInBits()

std::size_t ADS::DirectAccessCodes::sizeInBits ( void ) const
nodiscard

the bits of the chunks, of the continuation bits and of their ranks

◆ widths()

std::vector< int > ADS::DirectAccessCodes::widths ( void ) const
nodiscard

the widths of the chunks of the levels


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