ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
DirectAccessCodes.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------ File DirectAccessCodes.h ------------------------*/
3/*--------------------------------------------------------------------------*/
74/*--------------------------------------------------------------------------*/
75/*----------------------------- DEFINITIONS --------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78#ifndef __ADS_DirectAccessCodes
79 #define __ADS_DirectAccessCodes
80/* self-identification: #endif constant */
81
82/*--------------------------------------------------------------------------*/
83/*------------------------------ INCLUDES ----------------------------------*/
84/*--------------------------------------------------------------------------*/
85
86#include "ADS/Contract.h"
89
90#include <array>
91#include <bit>
92#include <cstddef>
93#include <cstdint>
94#include <cstring>
95#include <span>
96#include <vector>
97
98/*--------------------------------------------------------------------------*/
99/*--------------------------- NAMESPACE ------------------------------------*/
100/*--------------------------------------------------------------------------*/
101
102namespace ADS
103{
104
105/*--------------------------------------------------------------------------*/
106/*------------------------- CLASS DirectAccessCodes ------------------------*/
107/*--------------------------------------------------------------------------*/
108
111{
112
113/*--------------------------------------------------------------------------*/
114 public:
116 DirectAccessCodes( void ) = default;
117
120 enum class Levels : int {
121 UNCAPPED = 0 ,
123 };
124
158 explicit DirectAccessCodes( std::span< const std::uint64_t > x ,
160
167 DirectAccessCodes( std::span< const std::uint64_t > x , int b );
168
170 [[nodiscard]] std::size_t size( void ) const { return( f_n ); }
171
173 [[nodiscard]] bool empty( void ) const { return( f_n == 0 ); }
174
191 [[nodiscard]] std::uint64_t access( std::size_t i ) const;
192
194 [[nodiscard]] std::uint64_t operator[]( std::size_t i ) const {
195 return( access( i ) );
196 }
197
199 [[nodiscard]] std::vector< int > widths( void ) const;
200
202 [[nodiscard]] std::size_t sizeInBits( void ) const;
203
204/*------------------------- THE STANDARD INTERFACE -------------------------*/
205
206 using value_type = std::uint64_t;
207 using size_type = std::size_t;
208 using difference_type = std::ptrdiff_t;
209 using reference = std::uint64_t;
210 using const_reference = std::uint64_t;
214
216 [[nodiscard]] const_iterator begin( void ) const {
217 return( const_iterator( this , 0 ) );
218 }
219
221 [[nodiscard]] const_iterator end( void ) const {
222 return( const_iterator( this , f_n ) );
223 }
224
226 [[nodiscard]] const_iterator cbegin( void ) const { return( begin() ); }
227
229 [[nodiscard]] const_iterator cend( void ) const { return( end() ); }
230
231/*--------------------------------------------------------------------------*/
232 private:
235 struct Level
236 {
237 int width = 0 ,
238 shift = 0;
239 BitVector chunks;
241 RankSelect more;
242 };
243
245 void build( std::span< const std::uint64_t > x ,
246 const std::array< int , 65 > & cut , int w );
247
248 std::size_t f_n = 0;
249 std::vector< Level > f_lev;
250
251 }; // end( class DirectAccessCodes )
252
253/*--------------------------------------------------------------------------*/
254
255} // end( namespace ADS )
256
257/*--------------------------------------------------------------------------*/
258/*-------------------------- IMPLEMENTATION --------------------------------*/
259/*--------------------------------------------------------------------------*/
260
261#include "ADS/compression/impl/DirectAccessCodes.tpp"
262
263/*--------------------------------------------------------------------------*/
264
265#endif /* DirectAccessCodes.h included */
266
267/*--------------------------------------------------------------------------*/
268/*---------------------- End File DirectAccessCodes.h ----------------------*/
269/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
Rank and select on a static vector of bits of bits with 1s (chapter 15, Compressed Data Structures...
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
DirectAccessCodes(std::span< const std::uint64_t > x, Levels L=Levels::DEFAULT)
the sequence , with the widths of at most levels ( the value of , or if UNCAPPED) that minimize it...
std::ptrdiff_t difference_type
the type of the distances
Definition DirectAccessCodes.h:208
std::uint64_t operator[](std::size_t i) const
the item , by access()
Definition DirectAccessCodes.h:194
const_iterator cend(void) const
the same as end()
Definition DirectAccessCodes.h:229
Levels
the most levels of the widths that minimize the bits: a number , or no bound
Definition DirectAccessCodes.h:120
@ DEFAULT
at most 3 levels
Definition DirectAccessCodes.h:122
@ UNCAPPED
as many levels as minimize the bits
Definition DirectAccessCodes.h:121
const_iterator begin(void) const
the iterator at the first item
Definition DirectAccessCodes.h:216
std::size_t size_type
the type of the sizes
Definition DirectAccessCodes.h:207
std::uint64_t const_reference
an item, by value
Definition DirectAccessCodes.h:210
DirectAccessCodes(void)=default
the empty sequence
std::uint64_t reference
an item, by value
Definition DirectAccessCodes.h:209
std::size_t size(void) const
the number of the items
Definition DirectAccessCodes.h:170
std::uint64_t access(std::size_t i) const
the item
std::uint64_t value_type
the type of the items
Definition DirectAccessCodes.h:206
const_iterator end(void) const
the iterator past the last item
Definition DirectAccessCodes.h:221
std::vector< int > widths(void) const
the widths of the chunks of the levels
const_iterator iterator
the same as const_iterator
Definition DirectAccessCodes.h:213
DirectAccessCodes(std::span< const std::uint64_t > x, int b)
the sequence , with levels of bits each (the last one up to the bits of the largest item),...
bool empty(void) const
whether there is no item
Definition DirectAccessCodes.h:173
std::size_t sizeInBits(void) const
the bits of the chunks, of the continuation bits and of their ranks
const_iterator cbegin(void) const
the same as begin()
Definition DirectAccessCodes.h:226
SubscriptIterator< DirectAccessCodes, std::uint64_t > const_iterator
the iterator, by access()
Definition DirectAccessCodes.h:212
the random-access constant iterator on the items T of the owner O, read by ( *o )[ i ]
Definition BitVector.h:372
BasicRankSelect< false > RankSelect
the directory with its inventories of select built in the constructor, the fastest select
Definition RankSelect.h:556
Definition ADT.h:96