94 #define __ADS_LAVector
110#include <string_view>
159 explicit LAVector(
const std::vector< std::uint64_t > & x ,
int c = 7 );
181 [[nodiscard]]
static LAVector tuned(
const std::vector< std::uint64_t > & x );
184 [[nodiscard]] std::size_t
size(
void )
const;
187 [[nodiscard]]
bool empty(
void )
const;
208 [[nodiscard]] std::uint64_t
access( std::size_t i )
const;
212 [[nodiscard]] std::uint64_t
operator[]( std::size_t i )
const;
217 [[nodiscard]] std::uint64_t
select( std::size_t k )
const;
246 [[nodiscard]] std::size_t
nextGEQ( std::uint64_t x )
const;
249 [[nodiscard]] std::size_t
rank( std::uint64_t x )
const;
252 [[nodiscard]]
bool contains( std::uint64_t x )
const;
261 [[nodiscard]] std::vector< std::uint64_t >
decode(
void )
const;
312 using persist_unit = std::uint64_t;
320 std::vector< std::uint64_t > words;
322 std::uint64_t mask = 0;
323 std::size_t bits = 0;
327 void persist( A & a ) {
328 a( words , width , mask , bits );
329 a.require( ( width >= 0 ) && ( width <= 64 ) &&
330 ( words.size() * 64 >= bits ) ,
331 "the integers of a LAVector" );
335 void pack(
const std::vector< std::uint64_t > & v ) {
336 std::uint64_t top = 0;
337 for(
const auto x : v )
338 top = std::max( top , x );
339 width = top == 0 ? 0 :
lambda( top ) + 1;
341 mask = ( std::uint64_t( 1 ) << width ) - 1;
342 bits = v.size() * std::size_t( width );
343 words.assign( bits / 64 + 2 , 0 );
344 for( std::size_t i = 0 , b = 0 ; i < v.size() ; ++i , b += width ) {
345 words[ b / 64 ] |= v[ i ] << ( b % 64 );
346 if( b % 64 + std::size_t( width ) > 64 )
347 words[ b / 64 + 1 ] |= v[ i ] >> ( 64 - b % 64 );
352 [[nodiscard]] std::pair< std::size_t , std::size_t >
353 pair( std::size_t i )
const {
354 if constexpr( std::endian::native == std::endian::little )
356 const std::size_t b = i * std::size_t( width );
359 &x ,
reinterpret_cast< const unsigned char *
>( words.data() ) + b / 8 ,
362 return( std::make_pair( std::size_t( x & mask ) ,
363 std::size_t( ( x >> width ) & mask ) ) );
365 return( std::make_pair( ( *
this )[ i ] , ( *
this )[ i + 1 ] ) );
368 [[nodiscard]] std::size_t operator[]( std::size_t i )
const {
369 const std::size_t b = i * std::size_t( width );
370 if constexpr( std::endian::native == std::endian::little ) {
373 &x ,
reinterpret_cast< const unsigned char *
>( words.data() ) + b / 8 ,
375 return( std::size_t( ( x >> ( b % 8 ) ) & mask ) );
378 const std::size_t o = b % 64;
379 return( std::size_t( ( ( words[ b / 64 ] >> o ) |
380 ( ( words[ b / 64 + 1 ] << 1 ) << ( 63 - o ) ) ) &
391 [[nodiscard]]
static int widest(
const std::vector< std::uint64_t > & x );
394 [[nodiscard]]
static std::int64_t error(
int c );
398 void append(
const std::vector< std::uint64_t > & x , std::size_t f ,
399 std::size_t l ,
double a );
402 void finish(
const std::vector< std::uint64_t > & x );
406 [[nodiscard]]
static std::uint64_t whole(
double v );
409 [[nodiscard]] std::size_t segmentOf( std::size_t i , std::size_t & p )
const;
412 [[nodiscard]] std::uint64_t item( std::size_t j , std::size_t d )
const;
417 std::vector< Segment > f_seg;
419 std::vector< std::uint64_t > f_first;
424 std::uint64_t f_x0 = 0;
425 std::uint64_t f_last = 0;
437#include "ADS/succinct/impl/LAVector.tpp"
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,...
The piecewise geometric model index of Ferragina and Vinciguerra, beyond the book: a learned index on...
SubscriptIterator< LAVector, std::uint64_t > const_iterator
the constant iterator, random access
Definition LAVector.h:286
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 ,...
const_iterator cend(void) const
the same as end()
Definition LAVector.h:301
const_iterator begin(void) const
the iterator on the first item
Definition LAVector.h:291
std::ptrdiff_t difference_type
the type of the distance of two places
Definition LAVector.h:280
std::size_t size_type
the type of a size
Definition LAVector.h:278
bool contains(std::uint64_t x) const
whether is an item, by nextGEQ()
LAVector(const std::vector< std::uint64_t > &x, int c=7)
the sequence with corrections of bits, i.e., the error (0 for )
std::size_t segments(void) const
the number of segments,
std::size_t size(void) const
the number of items,
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition LAVector.h:266
bool empty(void) const
whether there is no item
std::uint64_t const_reference
an item, returned by value
Definition LAVector.h:284
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::uint64_t reference
an item, returned by value
Definition LAVector.h:282
std::vector< std::uint64_t > decode(void) const
the items, decoded in time
LAVector(void)=default
the empty sequence
std::uint64_t select(std::size_t k) const
the -th smallest item, i.e., access( k - 1 ), the select of the vector of bits whose 1s are the items
const_iterator end(void) const
the iterator past the last item
Definition LAVector.h:295
std::size_t rank(std::uint64_t x) const
the number of items , as nextGEQ()
const_iterator cbegin(void) const
the same as begin()
Definition LAVector.h:299
int correctionBits(void) const
the bits of the corrections asked for
std::uint64_t access(std::size_t i) const
the item
std::uint64_t operator[](std::size_t i) const
the item , as access()
const_iterator iterator
the same as const_iterator
Definition LAVector.h:288
std::size_t correctionsInBits(void) const
the bits of the corrections
std::size_t sizeInBits(void) const
all the bits: the corrections, the segments and the tables
std::uint64_t value_type
the type of an item
Definition LAVector.h:276
static LAVector tuned(const std::vector< std::uint64_t > &x)
the sequence with the of the fewest bits, among the odd ones up to of widest() and the two around ...
the random-access constant iterator on the items T of the owner O, read by ( *o )[ i ]
Definition BitVector.h:372
#define ADS_PRE(cond)
[check]
Definition Contract.h:121
constexpr int lambda(Word x)
the place of the leading 1 of ,
a segment of the array and its sum, with the place first and the length
Definition MaximumSegments.h:131