ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
RIndex.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*------------------------------ File RIndex.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
83/*--------------------------------------------------------------------------*/
84/*----------------------------- DEFINITIONS --------------------------------*/
85/*--------------------------------------------------------------------------*/
86
87#ifndef __ADS_RIndex
88 #define __ADS_RIndex
89/* self-identification: #endif constant */
90
91/*--------------------------------------------------------------------------*/
92/*------------------------------ INCLUDES ----------------------------------*/
93/*--------------------------------------------------------------------------*/
94
95#include "ADS/Contract.h"
100
101#include <algorithm>
102#include <array>
103#include <bit>
104#include <cstddef>
105#include <cstdint>
106#include <string>
107#include <string_view>
108#include <utility>
109#include <vector>
110
111/*--------------------------------------------------------------------------*/
112/*--------------------------- NAMESPACE ------------------------------------*/
113/*--------------------------------------------------------------------------*/
114
115namespace ADS
116{
117
118/*--------------------------------------------------------------------------*/
119/*------------------------------ CLASS RIndex ------------------------------*/
120/*--------------------------------------------------------------------------*/
121
125{
126
127/*--------------------------------------------------------------------------*/
128 public:
130 RIndex( void ) : RIndex( std::string_view() ) { }
131
163 explicit RIndex( std::string_view s );
164
166 [[nodiscard]] std::size_t size( void ) const { return( f_n ); }
167
169 [[nodiscard]] std::size_t runs( void ) const { return( f_start.size() ); }
170
197 [[nodiscard]] std::pair< std::size_t , std::size_t >
198 range( std::string_view P ) const;
199
210 [[nodiscard]] std::size_t count( std::string_view P ) const;
211
245 [[nodiscard]] std::vector< std::size_t > locate( std::string_view P ) const;
246
249 [[nodiscard]] std::size_t sizeInBits( void ) const;
250
251/*----------------------------- THE PERSISTENCE ----------------------------*/
252
254 static constexpr std::string_view persistName = "RIndex";
255
258 template< class A >
259 void persist( A & a );
260
261/*--------------------------------------------------------------------------*/
262 private:
264 [[nodiscard]] std::size_t rank( std::uint32_t c , std::size_t i ) const;
265
268 [[nodiscard]] std::size_t phi( std::size_t x ) const;
269
271 [[nodiscard]] static std::size_t get( const BitVector & v , int w ,
272 std::size_t i ) {
273 return( std::size_t( v.get( i * std::size_t( w ) , w ) ) );
274 }
275
276 std::size_t f_n = 0;
277 int f_w = 1;
278 EliasFano f_start;
280 EliasFano f_F;
281 std::array< std::size_t , 258 > f_R{};
282 std::array< std::size_t , 258 > f_C{};
283 BitVector f_end;
284 EliasFano f_key;
285 BitVector f_phi;
286 int f_wr = 1;
287#if ADS_CONTRACTS >= 3
288 std::string f_text;
289#endif
290
291 }; // end( class RIndex )
292
293/*--------------------------------------------------------------------------*/
294
295} // end( namespace ADS )
296
297/*--------------------------------------------------------------------------*/
298/*-------------------------- IMPLEMENTATION --------------------------------*/
299/*--------------------------------------------------------------------------*/
300
301#include "ADS/compression/impl/RIndex.tpp"
302
303/*--------------------------------------------------------------------------*/
304
305#endif /* RIndex.h included */
306
307/*--------------------------------------------------------------------------*/
308/*---------------------------- End File RIndex.h ---------------------------*/
309/*--------------------------------------------------------------------------*/
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The transform of Burrows and Wheeler and the compressor built on it (chapter 14, Block-Sorting Compre...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The Elias-Fano representation of a non-decreasing sequence of integers in (chapters 11,...
The wavelet tree shaped by the code of Huffman of Mäkinen and Navarro: a sequence of symbols of in ...
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
Word get(std::size_t i, int len) const
the bits from the place , the bit in the bit 0 of the result
a static sequence of symbols in about bits each, with access, rank and select in time proportional t...
Definition HuffmanWaveletTree.h:112
std::size_t size(void) const
the length of the text
Definition RIndex.h:166
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition RIndex.h:254
RIndex(void)
the index of the empty text
Definition RIndex.h:130
std::pair< std::size_t, std::size_t > range(std::string_view P) const
the range of the rows prefixed by , empty if none
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::vector< std::size_t > locate(std::string_view P) const
the places of the occurrences of , in increasing order
RIndex(std::string_view s)
the index of
std::size_t sizeInBits(void) const
the bits of the index: the runs, their heads, the sums of their lengths, the samples and the function
std::size_t runs(void) const
the number of the runs of the transform
Definition RIndex.h:169
std::size_t count(std::string_view P) const
the number of the occurrences of
BasicEliasFano< false > EliasFano
Elias-Fano with the inventories of built in the constructor, the fastest access() and nextGEQ().
Definition EliasFano.h:291
Definition ADT.h:96