ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::TwoLevelDictionary Class Reference

a Patricia trie on the anchors of a front-coded dictionary More...

#include <ADS/dictionary/TwoLevelDictionary.h>

Public types

using value_type = std::string
 the type of the items, for the standard library
using size_type = std::size_t
 the type of the sizes
using difference_type = std::ptrdiff_t
 the type of the distances between two iterators
using reference = const std::string &
 a reference to an item
using const_reference = const std::string &
 a constant reference to an item
using const_iterator = FrontCodedDictionary::const_iterator
 the iterator on the items, constant
using iterator = const_iterator
 the iterator on the items

Public member functions

 TwoLevelDictionary (FrontCodedDictionary F)
 the trie on the anchors of the coding \( F \)
std::size_t lexicographicPosition (std::string_view Q) const
 the number of strings smaller than \( Q \)
std::size_t prefixEnd (std::string_view P) const
 the number of strings smaller than \( P\# \), \( \# \) larger than every character, i.e., of the strings smaller than \( P \) or prefixed by it; as lexicographicPosition(), with \( P\# \) in the place of \( Q \)
std::pair< std::size_t, std::size_t > prefixRange (std::string_view P) const
 the range \( [ l , r ) \) of the strings prefixed by \( P \)
std::string access (std::size_t i) const
 the string \( i \), decoded from its bucket
std::size_t size (void) const
 the number of strings
const PatriciaTrie & upper (void) const
 the upper level, the trie on the anchors
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
const_iterator end (void) const
 the iterator past the last item
const_iterator cbegin (void) const
 the constant iterator on the first item
const_iterator cend (void) const
 the constant iterator past the last item

Detailed description

a Patricia trie on the anchors of a front-coded dictionary

Member typedef documentation

◆ const_iterator

◆ const_reference

using ADS::TwoLevelDictionary::const_reference = const std::string &

a constant reference to an item

◆ difference_type

the type of the distances between two iterators

◆ iterator

the iterator on the items

◆ reference

using ADS::TwoLevelDictionary::reference = const std::string &

a reference to an item

◆ size_type

the type of the sizes

◆ value_type

the type of the items, for the standard library

Constructor and destructor documentation

◆ TwoLevelDictionary()

ADS::TwoLevelDictionary::TwoLevelDictionary ( FrontCodedDictionary F)
explicit

the trie on the anchors of the coding \( F \)

Member function documentation

◆ access()

std::string ADS::TwoLevelDictionary::access ( std::size_t i) const
nodiscard

the string \( i \), decoded from its bucket

Precondition
\( i \) is less than size()

◆ begin()

const_iterator ADS::TwoLevelDictionary::begin ( void ) const
inlinenodiscard

the iterator on the first item

◆ cbegin()

const_iterator ADS::TwoLevelDictionary::cbegin ( void ) const
inlinenodiscard

the constant iterator on the first item

◆ cend()

const_iterator ADS::TwoLevelDictionary::cend ( void ) const
inlinenodiscard

the constant iterator past the last item

◆ end()

const_iterator ADS::TwoLevelDictionary::end ( void ) const
inlinenodiscard

the iterator past the last item

◆ lexicographicPosition()

std::size_t ADS::TwoLevelDictionary::lexicographicPosition ( std::string_view Q) const
nodiscard

the number of strings smaller than \( Q \)

In pseudocode (chapter 9 of Ferragina), the trie in memory and the buckets of the coding on disk:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{lexicographicPosition}( Q ) \cr 2 & \quad j \gets T.\mathrm{lexicographicPosition}( Q )\quad \triangleright\ \text{the blind search among the anchors} \cr 3 & \quad \textbf{return}\ \text{the rank of } Q \text{ in the bucket } \text{of the anchor } j \text{, decoded on the fly} \end{array}} \]

Postcondition
the strings before the result are smaller than \( Q \), the others are not

◆ lower()

const FrontCodedDictionary & ADS::TwoLevelDictionary::lower ( void ) const
nodiscard

the lower level, the front coding of the strings

◆ prefixEnd()

std::size_t ADS::TwoLevelDictionary::prefixEnd ( std::string_view P) const
nodiscard

the number of strings smaller than \( P\# \), \( \# \) larger than every character, i.e., of the strings smaller than \( P \) or prefixed by it; as lexicographicPosition(), with \( P\# \) in the place of \( Q \)

Postcondition
the strings before the result precede \( P\# \), the others do not

◆ prefixRange()

std::pair< std::size_t, std::size_t > ADS::TwoLevelDictionary::prefixRange ( std::string_view P) const
nodiscard

the range \( [ l , r ) \) of the strings prefixed by \( P \)

In pseudocode (chapter 9 of Ferragina):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{prefixRange}( P ) \cr 2 & \quad \textbf{return}\ ( \mathrm{lexicographicPosition}( P ) , \mathrm{prefixEnd}( P ) ) \end{array}} \]

◆ size()

std::size_t ADS::TwoLevelDictionary::size ( void ) const
nodiscard

the number of strings

◆ upper()

const PatriciaTrie & ADS::TwoLevelDictionary::upper ( void ) const
nodiscard

the upper level, the trie on the anchors


The documentation for this class was generated from the following file: