156#ifndef __ADS_SuffixArray
157 #define __ADS_SuffixArray
173#include <string_view>
205[[nodiscard]]
inline std::vector< std::size_t >
216[[nodiscard]]
inline std::vector< std::size_t >
247[[nodiscard]]
inline std::vector< std::size_t >
259[[nodiscard]]
inline std::vector< std::size_t >
289[[nodiscard]]
inline std::vector< std::size_t >
301[[nodiscard]]
inline std::vector< std::size_t >
332[[nodiscard]]
inline std::vector< std::size_t >
343[[nodiscard]]
inline std::vector< std::size_t >
389[[nodiscard]]
inline std::vector< std::size_t >
400[[nodiscard]]
inline std::vector< std::size_t >
430[[nodiscard]]
inline std::vector< std::size_t >
442[[nodiscard]]
inline std::vector< std::size_t >
446[[nodiscard]]
inline std::vector< std::size_t >
474[[nodiscard]]
inline std::vector< std::size_t >
486[[nodiscard]]
inline std::vector< std::size_t >
487lcpArray( std::string_view T ,
const std::vector< std::size_t > & SA );
553 [[nodiscard]] std::pair< std::size_t , std::size_t >
563 [[nodiscard]] std::pair< std::size_t , std::size_t >
564 range( std::string_view P ,
long * comparisons =
nullptr )
const;
596 [[nodiscard]] std::pair< std::size_t , std::size_t >
607 [[nodiscard]] std::pair< std::size_t , std::size_t >
608 rangeLcp( std::string_view P ,
long * comparisons =
nullptr )
const;
612 [[nodiscard]] std::size_t
count( std::string_view P )
const;
616 [[nodiscard]] std::vector< std::size_t >
locate( std::string_view P )
const;
639 [[nodiscard]] std::size_t
lce( std::size_t i , std::size_t j )
const;
643 [[nodiscard]] std::size_t
rank( std::size_t i )
const;
650 [[nodiscard]] std::size_t
size(
void )
const {
return( f_SA.size() ); }
653 [[nodiscard]]
const Symbols &
text(
void )
const {
return( f_T ); }
656 [[nodiscard]]
const std::vector< std::size_t > &
lcp(
void )
const {
692 std::size_t build(
long L ,
long R );
698 std::pair< std::size_t , bool > compare(
const Symbols & P , std::size_t M ,
699 std::size_t h ,
bool upper ,
700 long * comparisons )
const;
705 std::size_t bound(
const Symbols & P ,
bool upper ,
long * c )
const;
706 std::size_t boundLcp(
const Symbols & P ,
bool upper ,
long * c )
const;
709 std::vector< std::size_t > f_SA;
710 std::vector< std::size_t > f_rank;
711 std::vector< std::size_t > f_lcp;
712 std::vector< std::size_t > f_Llcp;
713 std::vector< std::size_t > f_Rlcp;
726#include "ADS/string/impl/SuffixArray.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The sorts by the digits of the keys, beyond the book (which has Counting Sort and Pigeonhole Sort,...
The range minimum query, beyond the book: given an array of items of an ordered universe,...
std::size_t lce(std::size_t i, std::size_t j) const
the length of the longest common prefix of the suffixes and ,
SuffixArray(std::string_view T)
the index of the bytes of , built by suffixArraySais() and lcpArray()
std::size_t value_type
a place of the text
Definition SuffixArray.h:664
const std::size_t & const_reference
an entry of SA
Definition SuffixArray.h:667
const_reference reference
an entry of SA
Definition SuffixArray.h:668
std::size_t size(void) const
the length of the text
Definition SuffixArray.h:650
const Symbols & text(void) const
the text
Definition SuffixArray.h:653
std::size_t count(std::string_view P) const
the number of occurrences of , the size of the range of rangeLcp()
std::pair< std::size_t, std::size_t > range(const Symbols &P, long *comparisons=nullptr) const
the range of of the suffixes prefixed by , by two binary searches; the comparisons of symbols go to...
std::ptrdiff_t difference_type
a difference of ranks
Definition SuffixArray.h:666
std::pair< std::size_t, std::size_t > range(std::string_view P, long *comparisons=nullptr) const
the range of range() above, of the bytes of
const std::vector< std::size_t > & lcp(void) const
the array , entries
Definition SuffixArray.h:656
SuffixArray(void)=default
the index of the empty text
SuffixArray(Symbols T, std::size_t K)
the index of an integer text, built as the one of the bytes above
std::vector< std::size_t >::const_iterator const_iterator
a constant iterator on the entries of SA
Definition SuffixArray.h:670
const_iterator cbegin(void) const
the first entry of
Definition SuffixArray.h:678
const_iterator iterator
on the entries of SA
Definition SuffixArray.h:671
const_iterator end(void) const
one past the last entry of
Definition SuffixArray.h:676
const_iterator begin(void) const
the first entry of
Definition SuffixArray.h:674
std::pair< std::size_t, std::size_t > rangeLcp(const Symbols &P, long *comparisons=nullptr) const
the range of range() by the search of Manber and Myers, comparisons of symbols
std::size_t operator[](std::size_t r) const
the place of the suffix of rank
std::vector< std::size_t > locate(std::string_view P) const
the places of the occurrences of , in the order of : the entries of the range of rangeLcp()
std::size_t size_type
the type of the ranks
Definition SuffixArray.h:665
std::vector< std::size_t > locate(const Symbols &P) const
the places of locate() above, of an integer pattern
std::size_t rank(std::size_t i) const
the rank of the suffix in
std::pair< std::size_t, std::size_t > rangeLcp(std::string_view P, long *comparisons=nullptr) const
the range of rangeLcp() above, of the bytes of
const_iterator cend(void) const
one past the last entry of
Definition SuffixArray.h:680
std::vector< std::size_t > lcpArray(E &ex, const S &T, const std::vector< std::size_t > &SA)
the LCP array of and of its suffix array on the threads of ex, entries (none if )
Definition ParallelText.h:161
std::vector< std::size_t > inversePermutation(const std::vector< std::size_t > &SA)
the inverse of a permutation:
std::vector< std::size_t > suffixArrayLarssonSadakane(const Symbols &T)
the suffix array of by the doubling of Larsson and Sadakane
std::vector< std::size_t > Symbols
a text on an integer alphabet
Definition SuffixArray.h:186
std::vector< std::size_t > suffixArraySorting(const Symbols &T)
the suffix array of by a sort of comparisons of its suffixes
Symbols toSymbols(std::string_view T)
the bytes of as symbols in
std::vector< std::size_t > suffixArraySkew(const Symbols &T, std::size_t K)
the suffix array of by the Skew algorithm of Kärkkäinen and Sanders
std::vector< std::size_t > suffixArrayDoubling(const Symbols &T)
the suffix array of by the prefix doubling of Manber and Myers
std::vector< std::size_t > suffixArraySais(const Symbols &T, std::size_t K)
the suffix array of by the induced sorting of Nong, Zhang and Chan
std::vector< std::size_t > suffixArrayScan(const Symbols &T, std::size_t m)
the suffix array of by the scan-based algorithm of Baeza-Yates, Gonnet and Snider,...