ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
TwoLevelDictionary.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------- File TwoLevelDictionary.h ------------------------*/
3/*--------------------------------------------------------------------------*/
52/*--------------------------------------------------------------------------*/
53/*----------------------------- DEFINITIONS --------------------------------*/
54/*--------------------------------------------------------------------------*/
55
56#ifndef __ADS_TwoLevelDictionary
57 #define __ADS_TwoLevelDictionary
58/* self-identification: #endif constant */
59
60/*--------------------------------------------------------------------------*/
61/*------------------------------ INCLUDES ----------------------------------*/
62/*--------------------------------------------------------------------------*/
63
64#include "ADS/Contract.h"
67
68#include <cstddef>
69#include <string>
70#include <string_view>
71#include <utility>
72#include <vector>
73
74/*--------------------------------------------------------------------------*/
75/*--------------------------- NAMESPACE ------------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78namespace ADS
79{
80
81/*--------------------------------------------------------------------------*/
82/*----------------------- CLASS TwoLevelDictionary -------------------------*/
83/*--------------------------------------------------------------------------*/
84
87{
88
89/*--------------------------------------------------------------------------*/
90 public:
93
109 [[nodiscard]] std::size_t lexicographicPosition( std::string_view Q ) const;
110
117 [[nodiscard]] std::size_t prefixEnd( std::string_view P ) const;
118
129 [[nodiscard]] std::pair< std::size_t , std::size_t >
130 prefixRange( std::string_view P ) const;
131
134 [[nodiscard]] std::string access( std::size_t i ) const;
135
137 [[nodiscard]] std::size_t size( void ) const;
138
140 [[nodiscard]] const PatriciaTrie & upper( void ) const;
141
143 [[nodiscard]] const FrontCodedDictionary & lower( void ) const;
144
145/*------------------------- THE STANDARD INTERFACE -------------------------*/
146
147 // the strings in their order, those of the lower level
148
150 using value_type = std::string;
152 using size_type = std::size_t;
154 using difference_type = std::ptrdiff_t;
156 using reference = const std::string &;
158 using const_reference = const std::string &;
163
165 [[nodiscard]] const_iterator begin( void ) const { return( f_F.begin() ); }
167 [[nodiscard]] const_iterator end( void ) const { return( f_F.end() ); }
169 [[nodiscard]] const_iterator cbegin( void ) const { return( begin() ); }
171 [[nodiscard]] const_iterator cend( void ) const { return( end() ); }
172
173/*--------------------------------------------------------------------------*/
174 private:
176 [[nodiscard]] static std::vector< std::string >
177 anchorsOf( const FrontCodedDictionary & F );
178
180 PatriciaTrie f_T;
181
182 }; // end( class TwoLevelDictionary )
183
184/*--------------------------------------------------------------------------*/
185
186} // end( namespace ADS )
187
188/*--------------------------------------------------------------------------*/
189/*-------------------------- IMPLEMENTATION --------------------------------*/
190/*--------------------------------------------------------------------------*/
191
192#include "ADS/dictionary/impl/TwoLevelDictionary.tpp"
193
194/*--------------------------------------------------------------------------*/
195
196#endif /* TwoLevelDictionary.h included */
197
198/*--------------------------------------------------------------------------*/
199/*--------------------- End File TwoLevelDictionary.h ----------------------*/
200/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The front coding of a sorted dictionary of strings, beyond the book: adjacent strings share a prefix,...
The Patricia trie with the blind search of Ferragina and Grossi, beyond the book: the compacted trie ...
a constant view of the strings in their order, decoded one after the other, forward; *it is the strin...
Definition FrontCoding.h:365
a sorted dictionary of strings in the front coding, with anchors
Definition FrontCoding.h:202
a sorted dictionary of strings on a Patricia trie, with the blind search
Definition PatriciaTrie.h:104
TwoLevelDictionary(FrontCodedDictionary F)
the trie on the anchors of the coding
std::size_t size_type
the type of the sizes
Definition TwoLevelDictionary.h:152
const_iterator iterator
the iterator on the items
Definition TwoLevelDictionary.h:162
std::string access(std::size_t i) const
the string , decoded from its bucket
const_iterator cend(void) const
the constant iterator past the last item
Definition TwoLevelDictionary.h:171
std::ptrdiff_t difference_type
the type of the distances between two iterators
Definition TwoLevelDictionary.h:154
const std::string & reference
a reference to an item
Definition TwoLevelDictionary.h:156
std::size_t lexicographicPosition(std::string_view Q) const
the number of strings smaller than
std::size_t size(void) const
the number of strings
std::string value_type
the type of the items, for the standard library
Definition TwoLevelDictionary.h:150
std::pair< std::size_t, std::size_t > prefixRange(std::string_view P) const
the range of the strings prefixed by
const_iterator cbegin(void) const
the constant iterator on the first item
Definition TwoLevelDictionary.h:169
const_iterator end(void) const
the iterator past the last item
Definition TwoLevelDictionary.h:167
const FrontCodedDictionary & lower(void) const
the lower level, the front coding of the strings
const_iterator begin(void) const
the iterator on the first item
Definition TwoLevelDictionary.h:165
const std::string & const_reference
a constant reference to an item
Definition TwoLevelDictionary.h:158
std::size_t prefixEnd(std::string_view P) const
the number of strings smaller than , larger than every character, i.e., of the strings smaller than ...
FrontCodedDictionary::const_iterator const_iterator
the iterator on the items, constant
Definition TwoLevelDictionary.h:160
const PatriciaTrie & upper(void) const
the upper level, the trie on the anchors
Definition ADT.h:96