ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
EliasFano.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*---------------------------- File EliasFano.h ----------------------------*/
3/*--------------------------------------------------------------------------*/
87/*--------------------------------------------------------------------------*/
88/*----------------------------- DEFINITIONS --------------------------------*/
89/*--------------------------------------------------------------------------*/
90
91#ifndef __ADS_EliasFano
92 #define __ADS_EliasFano
93/* self-identification: #endif constant */
94
95/*--------------------------------------------------------------------------*/
96/*------------------------------ INCLUDES ----------------------------------*/
97/*--------------------------------------------------------------------------*/
98
99#include "ADS/Contract.h"
103
104#include <algorithm>
105#include <cstddef>
106#include <cstdint>
107#include <string_view>
108#include <vector>
109
110/*--------------------------------------------------------------------------*/
111/*--------------------------- NAMESPACE ------------------------------------*/
112/*--------------------------------------------------------------------------*/
113
114namespace ADS
115{
116
117/*--------------------------------------------------------------------------*/
118/*-------------------------- CLASS BasicEliasFano --------------------------*/
119/*--------------------------------------------------------------------------*/
120
125template< bool Lazy >
127{
128
129/*--------------------------------------------------------------------------*/
130 public:
132 BasicEliasFano( void ) = default;
133
137 explicit BasicEliasFano( const std::vector< std::uint64_t > & x );
138
158 BasicEliasFano( const std::vector< std::uint64_t > & x , std::uint64_t u );
159
161 [[nodiscard]] std::size_t size( void ) const;
162
164 [[nodiscard]] bool empty( void ) const;
165
167 [[nodiscard]] std::uint64_t universe( void ) const;
168
183 [[nodiscard]] std::uint64_t access( std::size_t i ) const;
184
187 [[nodiscard]] std::uint64_t operator[]( std::size_t i ) const;
188
212 [[nodiscard]] std::size_t nextGEQ( std::uint64_t x ) const;
213
215 [[nodiscard]] bool contains( std::uint64_t x ) const;
216
218 [[nodiscard]] int lowWidth( void ) const;
219
221 [[nodiscard]] const BitVector & low( void ) const;
222
224 [[nodiscard]] const BasicRankSelect< Lazy > & high( void ) const;
225
227 [[nodiscard]] std::size_t codeBits( void ) const;
228
230 [[nodiscard]] std::size_t sizeInBits( void ) const;
231
233 [[nodiscard]] std::vector< std::uint64_t > decode( void ) const;
234
235/*----------------------------- THE PERSISTENCE ----------------------------*/
236
238 static constexpr std::string_view persistName =
239 Lazy ? "LazyEliasFano" : "EliasFano";
240
243 template< class A >
244 void persist( A & a );
245
246/*------------------------- THE STANDARD INTERFACE -------------------------*/
247
249 using value_type = std::uint64_t;
251 using size_type = std::size_t;
253 using difference_type = std::ptrdiff_t;
255 using reference = std::uint64_t;
257 using const_reference = std::uint64_t;
262
264 [[nodiscard]] const_iterator begin( void ) const {
265 return( const_iterator( this , 0 ) );
266 }
267
268 [[nodiscard]] const_iterator end( void ) const {
269 return( const_iterator( this , f_n ) );
270 }
271
272 [[nodiscard]] const_iterator cbegin( void ) const { return( begin() ); }
274 [[nodiscard]] const_iterator cend( void ) const { return( end() ); }
275
276/*--------------------------------------------------------------------------*/
277 private:
279 [[nodiscard]] std::uint64_t bucket( std::uint64_t x ) const;
280
281 std::size_t f_n = 0;
282 std::uint64_t f_u = 0;
283 int f_l = 0;
284 BitVector f_low;
286
287 }; // end( class BasicEliasFano )
288
292
296
297/*--------------------------------------------------------------------------*/
298
299} // end( namespace ADS )
300
301/*--------------------------------------------------------------------------*/
302/*-------------------------- IMPLEMENTATION --------------------------------*/
303/*--------------------------------------------------------------------------*/
304
305#include "ADS/succinct/impl/EliasFano.tpp"
306
307/*--------------------------------------------------------------------------*/
308
309#endif /* EliasFano.h included */
310
311/*--------------------------------------------------------------------------*/
312/*-------------------------- End File EliasFano.h --------------------------*/
313/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The broadword tricks of Knuth (section 7.1.3 of The Art of Computer Programming), beyond the book: op...
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...
std::uint64_t reference
an item, returned by value
Definition EliasFano.h:255
static constexpr std::string_view persistName
Definition EliasFano.h:238
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::size_t nextGEQ(std::uint64_t x) const
the place of the first item , size() if there is none, i.e., the number of items
int lowWidth(void) const
the number of low bits of each item,
const BasicRankSelect< Lazy > & high(void) const
the high bits, , with their directory
std::vector< std::uint64_t > decode(void) const
the items, decoded in time
const_iterator end(void) const
the iterator past the last item
Definition EliasFano.h:268
BasicEliasFano(void)=default
the empty sequence
BasicEliasFano(const std::vector< std::uint64_t > &x, std::uint64_t u)
the sequence in the universe
std::uint64_t const_reference
an item, returned by value
Definition EliasFano.h:257
const_iterator cend(void) const
the same as end()
Definition EliasFano.h:274
std::uint64_t value_type
the type of an item
Definition EliasFano.h:249
std::uint64_t universe(void) const
the bound of the items
BasicEliasFano(const std::vector< std::uint64_t > &x)
the sequence in the universe
std::size_t size_type
the type of a size
Definition EliasFano.h:251
std::uint64_t access(std::size_t i) const
the item
std::size_t codeBits(void) const
the bits of and , without the directory of
bool empty(void) const
whether there is no item
const_iterator begin(void) const
the iterator on the first item
Definition EliasFano.h:264
std::uint64_t operator[](std::size_t i) const
the item , as access()
std::ptrdiff_t difference_type
the type of the distance of two places
Definition EliasFano.h:253
bool contains(std::uint64_t x) const
whether is an item, by nextGEQ()
const_iterator iterator
the same as const_iterator
Definition EliasFano.h:261
const BitVector & low(void) const
the low bits,
const_iterator cbegin(void) const
the same as begin()
Definition EliasFano.h:272
std::size_t size(void) const
the number of items,
std::size_t sizeInBits(void) const
all the bits, with the directory of H
SubscriptIterator< BasicEliasFano, std::uint64_t > const_iterator
the constant iterator, random access
Definition EliasFano.h:259
a static vector of bits with rank and select in time, the inventories of select built in the constru...
Definition RankSelect.h:188
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
the random-access constant iterator on the items T of the owner O, read by ( *o )[ i ]
Definition BitVector.h:372
BasicEliasFano< false > EliasFano
Elias-Fano with the inventories of built in the constructor, the fastest access() and nextGEQ().
Definition EliasFano.h:291
BasicEliasFano< true > LazyEliasFano
Elias-Fano with the inventories of built at the first query that needs them, the fastest constructio...
Definition EliasFano.h:295
Definition ADT.h:96