ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
HuffmanFMIndex.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File HuffmanFMIndex.h -------------------------*/
3/*--------------------------------------------------------------------------*/
66/*--------------------------------------------------------------------------*/
67/*----------------------------- DEFINITIONS --------------------------------*/
68/*--------------------------------------------------------------------------*/
69
70#ifndef __ADS_HuffmanFMIndex
71 #define __ADS_HuffmanFMIndex
72/* self-identification: #endif constant */
73
74/*--------------------------------------------------------------------------*/
75/*------------------------------ INCLUDES ----------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78#include "ADS/Contract.h"
83
84#include <algorithm>
85#include <array>
86#include <bit>
87#include <cstddef>
88#include <cstdint>
89#include <string>
90#include <string_view>
91#include <utility>
92#include <vector>
93
94/*--------------------------------------------------------------------------*/
95/*--------------------------- NAMESPACE ------------------------------------*/
96/*--------------------------------------------------------------------------*/
97
98namespace ADS
99{
100
101/*--------------------------------------------------------------------------*/
102/*-------------------------- CLASS HuffmanFMIndex --------------------------*/
103/*--------------------------------------------------------------------------*/
104
107template< class RS = RankSelect >
109{
110
111/*--------------------------------------------------------------------------*/
112 public:
114 HuffmanFMIndex( void ) : HuffmanFMIndex( std::string_view() ) { }
115
137 explicit HuffmanFMIndex( std::string_view s , std::size_t mu = 32 );
138
140 [[nodiscard]] std::size_t size( void ) const { return( f_n ); }
141
163 [[nodiscard]] std::pair< std::size_t , std::size_t >
164 range( std::string_view P ) const;
165
176 [[nodiscard]] std::size_t count( std::string_view P ) const;
177
200 [[nodiscard]] std::vector< std::size_t > locate( std::string_view P ) const;
201
223 [[nodiscard]] std::string extract( std::size_t i , std::size_t j ) const;
224
227 [[nodiscard]] std::size_t sizeInBits( void ) const;
228
229/*----------------------------- THE PERSISTENCE ----------------------------*/
230
232 static constexpr std::string_view persistName = "HuffmanFMIndex";
233
235 [[nodiscard]] static constexpr std::uint64_t persistTag( void ) {
236 return( detail::persistHash( RS::persistName ) );
237 }
238
241 template< class A >
242 void persist( A & a );
243
244/*--------------------------------------------------------------------------*/
245 private:
247 [[nodiscard]] std::size_t place( std::size_t r ) const;
248
249 std::size_t f_n = 0 , f_mu = 1;
250 int f_w = 1;
252 std::array< std::size_t , 258 > f_C{};
253 CompactRankSelect f_mark;
254 BitVector f_place;
255 BitVector f_row;
256
257 }; // end( class HuffmanFMIndex )
258
259/*--------------------------------------------------------------------------*/
260
261} // end( namespace ADS )
262
263/*--------------------------------------------------------------------------*/
264/*-------------------------- IMPLEMENTATION --------------------------------*/
265/*--------------------------------------------------------------------------*/
266
267#include "ADS/compression/impl/HuffmanFMIndex.tpp"
268
269/*--------------------------------------------------------------------------*/
270
271#endif /* HuffmanFMIndex.h included */
272
273/*--------------------------------------------------------------------------*/
274/*------------------------ End File HuffmanFMIndex.h -----------------------*/
275/*--------------------------------------------------------------------------*/
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 wavelet tree shaped by the code of Huffman of Mäkinen and Navarro: a sequence of symbols of in ...
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
a static vector of bits with rank and select in 3.125% of its bits more for the rank and less than 0....
Definition CompactRankSelect.h:118
std::size_t size(void) const
the length of the text
Definition HuffmanFMIndex.h:140
std::pair< std::size_t, std::size_t > range(std::string_view P) const
the range of the rows prefixed by , empty if none
std::size_t sizeInBits(void) const
the bits of the index: the tree, the marks with their directory, the samples and the counts of the sy...
HuffmanFMIndex(std::string_view s, std::size_t mu=32)
the index of
std::size_t count(std::string_view P) const
the number of the occurrences of
std::vector< std::size_t > locate(std::string_view P) const
the places of the occurrences of , in increasing order
HuffmanFMIndex(void)
the index of the empty text
Definition HuffmanFMIndex.h:114
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
static constexpr std::uint64_t persistTag(void)
the directory of the bits, in a file
Definition HuffmanFMIndex.h:235
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition HuffmanFMIndex.h:232
std::string extract(std::size_t i, std::size_t j) const
the substring
a static sequence of symbols in about bits each, with access, rank and select in time proportional t...
Definition HuffmanWaveletTree.h:112
Definition ADT.h:96