ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SuccinctPatriciaTrie.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------- File SuccinctPatriciaTrie.h ----------------------*/
3/*--------------------------------------------------------------------------*/
70/*--------------------------------------------------------------------------*/
71/*----------------------------- DEFINITIONS --------------------------------*/
72/*--------------------------------------------------------------------------*/
73
74#ifndef __ADS_SuccinctPatriciaTrie
75 #define __ADS_SuccinctPatriciaTrie
76/* self-identification: #endif constant */
77
78/*--------------------------------------------------------------------------*/
79/*------------------------------ INCLUDES ----------------------------------*/
80/*--------------------------------------------------------------------------*/
81
82#include "ADS/Contract.h"
87
88#include <cstddef>
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 SuccinctPatriciaTrie ------------------------*/
103/*--------------------------------------------------------------------------*/
104
108{
109
110/*--------------------------------------------------------------------------*/
111 public:
114
146 explicit SuccinctPatriciaTrie( const std::vector< std::string > & D );
147
149 [[nodiscard]] std::size_t size( void ) const;
150
152 [[nodiscard]] bool empty( void ) const;
153
155 [[nodiscard]] std::size_t nodes( void ) const;
156
180 [[nodiscard]] std::size_t lookup( std::string_view Q ) const;
181
183 [[nodiscard]] bool contains( std::string_view Q ) const;
184
202 [[nodiscard]] std::string access( std::size_t i ) const;
203
206 [[nodiscard]] std::size_t lexicographicPosition( std::string_view Q ) const;
207
225 [[nodiscard]] std::pair< std::size_t , std::size_t >
226 prefixRange( std::string_view P ) const;
227
230 [[nodiscard]] std::size_t bytes( void ) const;
231
232/*--------------------------------------------------------------------------*/
233 private:
235 [[nodiscard]] std::size_t node( std::size_t p ) const;
236
238 [[nodiscard]] std::size_t place( std::size_t v ) const;
239
241 [[nodiscard]] std::string_view rest( std::size_t v ) const;
242
245 [[nodiscard]] std::size_t close( std::size_t p ) const;
246
250 [[nodiscard]] std::size_t start( std::size_t q ) const;
251
256 [[nodiscard]] std::size_t child( std::size_t c , std::size_t i ) const;
257
259 [[nodiscard]] std::size_t subtreeEnd( std::size_t p ) const;
260
262 [[nodiscard]] std::pair< std::size_t , std::size_t >
263 walk( std::string_view P ) const;
264
265 std::size_t f_n = 0;
267 std::string f_first;
268 CompactRankSelect f_end;
269 CompactRankSelect f_hasRest;
270 std::string f_rest;
271 EliasFano f_restAt;
272
273 }; // end( class SuccinctPatriciaTrie )
274
275/*--------------------------------------------------------------------------*/
276
277} // end( namespace ADS )
278
279/*--------------------------------------------------------------------------*/
280/*-------------------------- IMPLEMENTATION --------------------------------*/
281/*--------------------------------------------------------------------------*/
282
283#include "ADS/dictionary/impl/SuccinctPatriciaTrie.tpp"
284
285/*--------------------------------------------------------------------------*/
286
287#endif /* SuccinctPatriciaTrie.h included */
288
289/*--------------------------------------------------------------------------*/
290/*--------------------- End File SuccinctPatriciaTrie.h --------------------*/
291/*--------------------------------------------------------------------------*/
A static sequence of balanced parentheses, 1 for an open one and 0 for a closed one,...
Rank and select on a static vector of bits of bits in 3.125% of bits more for the rank and less th...
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 search by prefix in a sorted dictionary of strings, beyond the book: the strings prefixed by ar...
a static sequence of balanced parentheses with a range min-max tree
Definition BalancedParentheses.h:124
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 number of strings
std::size_t lexicographicPosition(std::string_view Q) const
the number of strings smaller than , by the walk of lookup() up to the first mismatch and the end of ...
SuccinctPatriciaTrie(void)
the empty dictionary
SuccinctPatriciaTrie(const std::vector< std::string > &D)
the trie of the strings of
std::pair< std::size_t, std::size_t > prefixRange(std::string_view P) const
the range of the ranks of the strings prefixed by , empty at lexicographicPosition( P ) if there is ...
std::size_t lookup(std::string_view Q) const
the rank of in the dictionary, size() if it is not there
std::size_t bytes(void) const
the bytes of the structure: the parentheses with their directory and tree, the first characters,...
bool empty(void) const
whether there is no string
bool contains(std::string_view Q) const
whether is a string of the dictionary, by lookup()
std::string access(std::size_t i) const
the string of rank
std::size_t nodes(void) const
the nodes of the compacted trie,
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