a sorted dictionary of strings in the front coding, with anchors
More...
#include <ADS/string/FrontCoding.h>
|
| class | const_iterator |
| | a constant view of the strings in their order, decoded one after the other, forward; *it is the string decoded in the iterator More...
|
|
| std::string | access (std::size_t i) const |
| | the string \( i \), decoded from the anchor before it
|
| std::size_t | decodeCost (std::size_t i) const |
| | the characters that access( i ) reads, those of the rests from the anchor before \( i \) to \( i \)
|
| 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\# \)
|
| std::pair< std::size_t, std::size_t > | prefixRange (std::string_view P) const |
| | the range \( [ l , r ) \) of the strings prefixed by \( P \), by lexicographicPosition() and prefixEnd()
|
| std::size_t | rankInBucket (std::size_t k, std::string_view P, bool upper) const |
| | the number of strings smaller than \( P \) (or \( P\# \) if upper), given that \( k \) anchors are: the scan of the bucket \( k - 1 \)
|
| std::size_t | size (void) const |
| | the number \( n \) of strings
|
| std::size_t | anchors (void) const |
| | the number of anchors, the strings stored whole
|
| std::size_t | anchor (std::size_t k) const |
| | the place in the dictionary of the anchor \( k \)
|
| std::string_view | anchorString (std::size_t k) const |
| | the string of the anchor \( k \)
|
| std::size_t | characters (void) const |
| | the characters of the coding, those of the rests and of the anchors
|
| std::size_t | bytes (void) const |
| | the bytes of the coding, the characters and the codes of the lengths
|
| const_iterator | begin (void) const |
| | the first string
|
| const_iterator | end (void) const |
| | past the last string
|
| const_iterator | cbegin (void) const |
| | the first string
|
| const_iterator | cend (void) const |
| | past the last string
|
|
| static FrontCodedDictionary | bucketed (const std::vector< std::string > &D, std::size_t b) |
| | the front coding of \( D \) with an anchor every \( b \) strings
|
| static FrontCodedDictionary | localityPreserving (const std::vector< std::string > &D, double c) |
| | the locality-preserving front coding of \( D \), of parameter \( c \)
|
a sorted dictionary of strings in the front coding, with anchors
◆ const_reference
◆ difference_type
◆ iterator
◆ reference
◆ size_type
◆ value_type
◆ access()
| std::string ADS::FrontCodedDictionary::access |
( |
std::size_t | i | ) |
const |
|
nodiscard |
the string \( i \), decoded from the anchor before it
In pseudocode (the front coding of chapter 9, Searching Strings by Prefix, of Ferragina's book, beyond the book), \( a \) the last anchor at or before \( i \), found by a binary search:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{access}( i ) \cr
2 & \quad a \gets \text{the last anchor} \le i;\ s \gets \hat s_a \cr
3 & \quad \textbf{for}\ j \gets a + 1\ \textbf{to}\ i\ \textbf{do}\ s
\gets s[ 0 .. \ell_j - 1 ] \cdot \hat s_j \cr
4 & \quad \textbf{return}\ s
\end{array}}
\]
- Precondition
- \( i \) is less than size()
◆ anchor()
| std::size_t ADS::FrontCodedDictionary::anchor |
( |
std::size_t | k | ) |
const |
|
nodiscard |
the place in the dictionary of the anchor \( k \)
- Precondition
- \( k \) is less than anchors()
◆ anchors()
| std::size_t ADS::FrontCodedDictionary::anchors |
( |
void | | ) |
const |
|
nodiscard |
the number of anchors, the strings stored whole
◆ anchorString()
| std::string_view ADS::FrontCodedDictionary::anchorString |
( |
std::size_t | k | ) |
const |
|
nodiscard |
the string of the anchor \( k \)
- Precondition
- \( k \) is less than anchors()
◆ begin()
◆ bucketed()
| FrontCodedDictionary ADS::FrontCodedDictionary::bucketed |
( |
const std::vector< std::string > & | D, |
|
|
std::size_t | b ) |
|
staticnodiscard |
the front coding of \( D \) with an anchor every \( b \) strings
In pseudocode (the front coding with bucketing of chapter 9, Searching Strings by Prefix, of Ferragina's book, beyond the book), the coding that localityPreserving() shares with another rule for the anchors:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{bucketed}( D , b ) \cr
2 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do} \cr
3 & \qquad \textbf{if}\ i \bmod b = 0\ \textbf{then}\ \ell_i \gets 0;
\ \text{make } i \text{ an anchor} \cr
4 & \qquad \textbf{else}\ \ell_i \gets \mathrm{commonPrefixLength}(
s_{i-1} , s_i ) \cr
5 & \qquad \text{append } s_i[ \ell_i .. |s_i| - 1 ] \text{ to the }
\text{characters of the coding} \cr
6 & \quad \textbf{return}\ \text{the coding}
\end{array}}
\]
- Precondition
- \( D \) is sorted (audit) and \( b \ge 1 \)
◆ bytes()
| std::size_t ADS::FrontCodedDictionary::bytes |
( |
void | | ) |
const |
|
nodiscard |
the bytes of the coding, the characters and the codes of the lengths
◆ cbegin()
◆ cend()
◆ characters()
| std::size_t ADS::FrontCodedDictionary::characters |
( |
void | | ) |
const |
|
nodiscard |
the characters of the coding, those of the rests and of the anchors
◆ decodeCost()
| std::size_t ADS::FrontCodedDictionary::decodeCost |
( |
std::size_t | i | ) |
const |
|
nodiscard |
the characters that access( i ) reads, those of the rests from the anchor before \( i \) to \( i \)
- Precondition
- \( i \) is less than size()
◆ end()
◆ lexicographicPosition()
| std::size_t ADS::FrontCodedDictionary::lexicographicPosition |
( |
std::string_view | Q | ) |
const |
|
nodiscard |
the number of strings smaller than \( Q \)
In pseudocode (the two-level search of chapter 9, Searching Strings by Prefix, of Ferragina's book, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{lexicographicPosition}( Q ) \cr
2 & \quad k \gets \text{the number of anchors smaller than } Q
\text{, by a binary search} \cr
3 & \quad \textbf{return}\ \mathrm{rankInBucket}( k , Q ,
\textbf{false} )
\end{array}}
\]
◆ localityPreserving()
| FrontCodedDictionary ADS::FrontCodedDictionary::localityPreserving |
( |
const std::vector< std::string > & | D, |
|
|
double | c ) |
|
staticnodiscard |
the locality-preserving front coding of \( D \), of parameter \( c \)
In pseudocode (Bender, Farach-Colton and Kuszmaul, beyond the book), \( \mathit{chars} \) the characters of the coding since the last anchor began:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{localityPreserving}( D , c ) \cr
2 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do} \cr
3 & \qquad \ell_i \gets 0 \text{ if } i = 0 \text{, else }
\mathrm{commonPrefixLength}( s_{i-1} , s_i ) \cr
4 & \qquad \textbf{if}\ i = 0\ \textbf{or}\ \ell_i = 0\ \textbf{or}
\ \mathit{chars} > c | s_i |\ \textbf{then} \cr
5 & \qquad\quad \ell_i \gets 0;\ \text{make } i \text{ an anchor};
\ \mathit{chars} \gets 0 \cr
6 & \qquad \text{append } s_i[ \ell_i .. |s_i| - 1 ] \text{ to the }
\text{coding};\ \mathit{chars} \gets \mathit{chars} + |s_i| -
\ell_i \cr
7 & \quad \textbf{return}\ \text{the coding}
\end{array}}
\]
- Precondition
- \( D \) is sorted (audit) and \( c > 0 \)
- Postcondition
- for \( c > 2 \), characters() is at most \( ( 1 + 2 / ( c - 2 ) ) \, \mathit{FC}( D ) \) and decodeCost( i ) at most \( ( c + 1 ) | s_i | \)
◆ prefixEnd()
| std::size_t ADS::FrontCodedDictionary::prefixEnd |
( |
std::string_view | P | ) |
const |
|
nodiscard |
the number of strings smaller than \( P\# \)
In pseudocode (the two-level search of chapter 9, Searching Strings by Prefix, of Ferragina's book, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{prefixEnd}( P ) \cr
2 & \quad k \gets \text{the number of anchors smaller than } P\#
\text{, by a binary search} \cr
3 & \quad \textbf{return}\ \mathrm{rankInBucket}( k , P , \textbf{true}
)
\end{array}}
\]
◆ prefixRange()
| std::pair< std::size_t, std::size_t > ADS::FrontCodedDictionary::prefixRange |
( |
std::string_view | P | ) |
const |
|
nodiscard |
◆ rankInBucket()
| std::size_t ADS::FrontCodedDictionary::rankInBucket |
( |
std::size_t | k, |
|
|
std::string_view | P, |
|
|
bool | upper ) const |
|
nodiscard |
the number of strings smaller than \( P \) (or \( P\# \) if upper), given that \( k \) anchors are: the scan of the bucket \( k - 1 \)
In pseudocode (the two-level search of chapter 9, Searching Strings by Prefix, of Ferragina's book, beyond the book), the strings of the bucket decoded on the fly, \( e \) the next anchor (or \( n \)):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{rankInBucket}( k , P , \mathit{upper} ) \cr
2 & \quad \textbf{if}\ k = 0\ \textbf{then return}\ 0 \cr
3 & \quad i \gets \text{the anchor } k - 1;\ s \gets \hat s_i \cr
4 & \quad \textbf{while}\ i < e\ \textbf{and}\ s \text{ precedes } P
\text{ (or } P\# \text{)}\ \textbf{do} \cr
5 & \qquad i \gets i + 1 \cr
6 & \qquad \textbf{if}\ i < e\ \textbf{then}\ s \gets s[ 0 .. \ell_i - 1
] \cdot \hat s_i \cr
7 & \quad \textbf{return}\ i
\end{array}}
\]
- Precondition
- \( k \) is at most anchors(), and it is the number of anchors that precede the pattern
◆ size()
| std::size_t ADS::FrontCodedDictionary::size |
( |
void | | ) |
const |
|
nodiscard |
the number \( n \) of strings
The documentation for this class was generated from the following file: