|
ADS
Algorithms and Data Structures
|
The two-level dictionary of strings, beyond the book: the lower level is the front coding of the sorted strings with anchors [see FrontCodedDictionary in FrontCoding.h], the strings that are stored whole, either one every \( b \) (the bucketing) or as the locality-preserving coding decides, and the upper level a Patricia trie [see PatriciaTrie.h] on the anchors alone. More...
#include "ADS/Contract.h"#include "ADS/dictionary/PatriciaTrie.h"#include "ADS/string/FrontCoding.h"#include <cstddef>#include <string>#include <string_view>#include <utility>#include <vector>#include "ADS/dictionary/impl/TwoLevelDictionary.tpp"Go to the source code of this file.
Classes | |
| class | ADS::TwoLevelDictionary |
| a Patricia trie on the anchors of a front-coded dictionary More... | |
Namespaces | |
| namespace | ADS |
The two-level dictionary of strings, beyond the book: the lower level is the front coding of the sorted strings with anchors [see FrontCodedDictionary in FrontCoding.h], the strings that are stored whole, either one every \( b \) (the bucketing) or as the locality-preserving coding decides, and the upper level a Patricia trie [see PatriciaTrie.h] on the anchors alone.
A search by prefix is the blind search of the pattern among the anchors, which reads one anchor, and the scan of the one bucket where the pattern falls, decoded on the fly: with the trie in memory and the coding on disk, \( O( p / B + | s | / B ) \) transfers of blocks for a pattern of \( p \) characters, \( s \) being the string read by the blind search, plus the bucket (chapter 9 of Ferragina), in \( O( n_a ) \) words of memory for \( n_a \) anchors and \( ( 1 + \epsilon ) \mathrm{FC}( D ) \) characters on disk with the locality-preserving coding. The upper level is independent of the lower one: a binary search on the anchors [see FrontCodedDictionary::lexicographicPosition()] costs \( O( ( p / B ) \log n_a ) \) transfers instead. When even the trie does not fit in memory, the string B-tree of Ferragina and Grossi splits it into Patricia tries of a block each, linked as a B-tree, for \( O( ( p + N_{occ} ) / B + \log_B n ) \) transfers.
The contracts [see Contract.h]: those of FrontCodedDictionary and of PatriciaTrie; each position \( r \) is such that the strings before \( r \) are smaller than the pattern (or than \( P\# \)) and those from \( r \) on are not, a postcondition. The functions are defined in TwoLevelDictionary.tpp.