|
ADS
Algorithms and Data Structures
|
The engineered longest common extensions of a text, beyond the book: the value \( \mathrm{lce}( i , j ) \) of the suffixes \( i \) and \( j \) of \( T \), the length of their longest common prefix, which the benchmark of the suffix arrays compares with the lce() of SuffixArray.h (the range minimum of Bender and Farach-Colton), with a range minimum of sdsl-lite and with the direct comparison of the two suffixes, while SuffixArray.h stays the textbook. More...
#include "ADS/Contract.h"#include "ADS/Portable.h"#include "ADS/SimdInline.h"#include "ADS/memory/Prefetch.h"#include "ADS/string/SuffixSorting.h"#include <concepts>#include <cstddef>#include <cstdint>#include <string>#include <string_view>#include <vector>#include "ADS/string/impl/LongestCommonExtension.tpp"Go to the source code of this file.
Classes | |
| class | ADS::LceIndex< I > |
| the longest common extensions of the suffixes of a text, \( O( 1 ) \) each, on unsigned integers I of 32 or 64 bits More... | |
Namespaces | |
| namespace | ADS |
The engineered longest common extensions of a text, beyond the book: the value \( \mathrm{lce}( i , j ) \) of the suffixes \( i \) and \( j \) of \( T \), the length of their longest common prefix, which the benchmark of the suffix arrays compares with the lce() of SuffixArray.h (the range minimum of Bender and Farach-Colton), with a range minimum of sdsl-lite and with the direct comparison of the two suffixes, while SuffixArray.h stays the textbook.
With \( \mathit{SA} \) the suffix array of \( T \), \( \mathit{SA}^{-1} \) its inverse and \( \mathit{LCP} \) its LCP array (\( \mathit{LCP}[ r ] \) the lcp of the suffixes \( \mathit{SA}[ r ] \) and \( \mathit{SA}[ r + 1 ] \)),
\[ \mathrm{lce}( i , j ) = \min_{ a \le r < b } \mathit{LCP}[ r ] , \qquad a = \min( \mathit{SA}^{-1}[ i ] , \mathit{SA}^{-1}[ j ] ) , \; b = \max( \mathit{SA}^{-1}[ i ] , \mathit{SA}^{-1}[ j ] ) , \]
a range minimum query; LceIndex builds \( \mathit{SA} \) by suffixArray() and \( \mathit{LCP} \) by lcpArrayPhi() [see SuffixSorting.h], and answers in two stages:
The space is \( 4 n \) bytes for each of \( \mathit{SA}^{-1} \) and \( \mathit{LCP} \) (on 32 bits), \( 2 n \) for the words, \( 1.75 n \) for the tables inside the groups and a vanishing share for the table of the groups, against the \( 2 n + o( n ) \) bits of the succinct range minima of Fischer and Heun, whose practical form (Baumstark, Gog, Heuer and Labeit) pays for its space with a select on a balanced-parentheses sequence at each query.
The contracts [see Contract.h]: a query asks for \( i , j \le n \) (\( n \) gives 0), and its answer is the lcp of the two suffixes (an audit, linear in it). The functions are defined in LongestCommonExtension.tpp.