81#ifndef __ADS_CompactRankSelect
82 #define __ADS_CompactRankSelect
101#include <string_view>
156 template< Executor E >
162 template< Executor E >
169 [[nodiscard]] std::size_t
size(
void )
const {
return( f_b.size() ); }
173 [[nodiscard]]
bool operator[]( std::size_t i )
const {
return( f_b[ i ] ); }
176 [[nodiscard]] std::size_t
ones(
void )
const {
return( f_ones ); }
179 [[nodiscard]] std::size_t
zeros(
void )
const {
180 return( f_b.size() - f_ones );
202 [[nodiscard]] std::size_t
rank1( std::size_t i )
const;
207 [[nodiscard]] std::size_t
rank0( std::size_t i )
const {
208 return( i -
rank1( i ) );
235 [[nodiscard]] std::size_t
select1( std::size_t k )
const;
241 [[nodiscard]] std::size_t
select0( std::size_t k )
const;
279 static constexpr std::string_view
persistName =
"CompactRankSelect";
282 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
284 detail::persistMix( { kSuper , kBlock , kSample ,
285 std::uint64_t( kTop ) } ) );
295 static constexpr std::size_t kSuper = 4096;
296 static constexpr std::size_t kBlock = 512;
297 static constexpr std::size_t kSample = 4096;
298#ifndef ADS_COMPACT_TOP
299 static constexpr int kTop = 32;
301 static constexpr int kTop = ADS_COMPACT_TOP;
309 using persist_unit = std::uint64_t;
310 std::uint64_t lo = 0 ,
316 [[nodiscard]]
static Entry entry(
const std::uint64_t ( &v )[ 9 ] ,
320#ifndef ADS_COMPACT_SCALAR
321 static constexpr bool kScalar =
false;
323 static constexpr bool kScalar =
true;
327 [[nodiscard]]
static std::size_t inSuper(
const Entry & e , std::size_t k ) {
328 const std::size_t s = 32 + 12 * k;
329 const std::uint64_t v =
330 s < 64 ? ( e.lo >> s ) | ( e.hi << ( 64 - s ) ) : e.hi >> ( s - 64 );
331 return( std::size_t( v & 0xFFF ) );
336#ifndef ADS_RANKSELECT_FUSE
337 static constexpr std::size_t kFuse = std::size_t( 1 ) << 23;
339 static constexpr std::size_t kFuse = ADS_RANKSELECT_FUSE;
344 void directory(
const Word * w );
347#ifndef ADS_COMPACT_CHUNK
348 static constexpr std::size_t kChunk = 256;
350 static constexpr std::size_t kChunk = ADS_COMPACT_CHUNK;
355 template< Executor E >
356 void directory( E & ex ,
const Word * w );
359 void closeSamples(
void );
362 [[nodiscard]] std::size_t before( std::size_t s ,
bool b )
const;
365 [[nodiscard]] std::size_t select( std::size_t k ,
bool b )
const;
368 [[nodiscard]]
bool consistent(
void )
const;
372 std::vector< Entry , MappableAllocator< Entry > > f_e;
373 std::vector< std::uint64_t > f_top;
375 std::vector< std::uint32_t , MappableAllocator< std::uint32_t > > f_s[ 2 ];
376 std::size_t f_ones = 0;
388#include "ADS/succinct/impl/CompactRankSelect.tpp"
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,...
The layer of execution of the parallel algorithms of ADS, beyond the book: an executor runs the calls...
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
std::size_t ones(void) const
the number of 1s
Definition CompactRankSelect.h:176
const_iterator iterator
the same as const_iterator
Definition CompactRankSelect.h:261
const_iterator cend(void) const
the same as end()
Definition CompactRankSelect.h:274
std::size_t rank1(std::size_t i) const
the number of 1s in the places
bool operator[](std::size_t i) const
the bit
Definition CompactRankSelect.h:173
static constexpr std::uint64_t persistTag(void)
the parameters of the layout of the directory, in a file
Definition CompactRankSelect.h:282
const_iterator cbegin(void) const
the same as begin()
Definition CompactRankSelect.h:272
bool value_type
the type of an item
Definition CompactRankSelect.h:249
std::ptrdiff_t difference_type
the type of the distance of two places
Definition CompactRankSelect.h:253
const_iterator begin(void) const
the iterator on the first item
Definition CompactRankSelect.h:264
std::size_t size(void) const
the number of bits,
Definition CompactRankSelect.h:169
std::size_t rank0(std::size_t i) const
the number of 0s in the places , i.e.,
Definition CompactRankSelect.h:207
std::size_t zeros(void) const
the number of 0s
Definition CompactRankSelect.h:179
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
CompactRankSelect(BitVector b)
the directory of the bits , which it keeps
CompactRankSelect(E &ex, std::span< const Word > w, std::size_t n)
the directory of CompactRankSelect( w , n ) above, the words copied by the chunks that count them,...
const BitVector & bits(void) const
the bits
Definition CompactRankSelect.h:166
std::size_t size_type
the type of a size
Definition CompactRankSelect.h:251
const_iterator end(void) const
the iterator past the last item
Definition CompactRankSelect.h:268
std::size_t select1(std::size_t k) const
the place of the -th 1
bool reference
an item, returned by value
Definition CompactRankSelect.h:255
SubscriptIterator< CompactRankSelect, bool > const_iterator
the constant iterator, random access
Definition CompactRankSelect.h:259
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition CompactRankSelect.h:279
std::size_t select0(std::size_t k) const
the place of the -th 0, by the select of select1() above on the complemented words
bool const_reference
an item, returned by value
Definition CompactRankSelect.h:257
CompactRankSelect(E &ex, BitVector b)
the directory of CompactRankSelect( b ) above, the same entries and samples, built on the threads of ...
std::size_t directoryBits(void) const
the bits of the directory, beyond those of the vector
CompactRankSelect(std::span< const Word > w, std::size_t n)
the directory of the bits of the words , copied as they are counted
CompactRankSelect(void)
the directory of no bit
Definition CompactRankSelect.h:123
the random-access constant iterator on the items T of the owner O, read by ( *o )[ i ]
Definition BitVector.h:372
std::uint64_t Word
a word of 64 bits
Definition Bitwise.h:73