|
ADS
Algorithms and Data Structures
|
The rear coding of a sorted dictionary of strings, beyond the book, and a compact dictionary on it (see Dictionaries searched by prefix). More...
Files | |
| file | ADS/string/RearCoding.h |
| The rear coding of a sorted dictionary of strings, beyond the book, and a compact dictionary on it (see Dictionaries searched by prefix): the front coding [see FrontCoding.h] writes the string \( s_i \) as the length \( \ell_i \) of the prefix it shares with \( s_{i-1} \) and the rest \( \hat s_i \); the rear coding writes instead \( r_i = | s_{i-1} | - \ell_i \), the characters to take off the end of \( s_{i-1} \) before appending \( \hat s_i \). | |
Classes | |
| class | ADS::RearCodedDictionary |
| a sorted dictionary of strings in the rear coding with buckets, in one string of bytes More... | |
Typedefs | |
| using | ADS::RearPair = std::pair< std::size_t , std::string > |
| a pair \( ( r , \hat s ) \) of the rear coding, the characters taken off the end of the string before and the rest | |
Functions | |
| std::vector< RearPair > | ADS::rearCode (const std::vector< std::string > &D) |
| the rear coding of \( D \), a pair per string | |
| std::vector< std::string > | ADS::rearDecode (const std::vector< RearPair > &R) |
| the strings of the rear coding \( R \) | |
The rear coding of a sorted dictionary of strings, beyond the book, and a compact dictionary on it (see Dictionaries searched by prefix).
The definitions, the invariants and the costs of the area are in Theory of strings.
| using ADS::RearPair = std::pair< std::size_t , std::string > |
a pair \( ( r , \hat s ) \) of the rear coding, the characters taken off the end of the string before and the rest
|
inlinenodiscard |
the rear coding of \( D \), a pair per string
In pseudocode (Ferragina, Grossi, Gupta, Shah and Vitter, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{rearCode}( D ) \cr 2 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ n - 1\ \textbf{do} \cr 3 & \qquad \ell \gets 0 \text{ if } i = 0 \text{, else } \mathrm{commonPrefixLength}( s_{i-1} , s_i ) \cr 4 & \qquad R[ i ] \gets ( | s_{i-1} | - \ell , s_i[ \ell .. |s_i| - 1 ] )\quad \triangleright\ | s_{-1} | = 0 \cr 5 & \quad \textbf{return}\ R \end{array}} \]
|
inlinenodiscard |
the strings of the rear coding \( R \)
In pseudocode (Ferragina, Grossi, Gupta, Shah and Vitter, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{rearDecode}( R ) \cr 2 & \quad s \gets \text{the empty string} \cr 3 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ |R| - 1\ \textbf{do} \cr 4 & \qquad ( r , \hat s ) \gets R[ i ];\ s \gets s[ 0 .. |s| - r - 1 ] \cdot \hat s;\ s_i \gets s \cr 5 & \quad \textbf{return}\ ( s_0 , \ldots , s_{|R| - 1} ) \end{array}} \]