ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SuffixApplications.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------- File SuffixApplications.h ------------------------*/
3/*--------------------------------------------------------------------------*/
95/*--------------------------------------------------------------------------*/
96/*----------------------------- DEFINITIONS --------------------------------*/
97/*--------------------------------------------------------------------------*/
98
99#ifndef __ADS_SuffixApplications
100 #define __ADS_SuffixApplications
101/* self-identification: #endif constant */
102
103/*--------------------------------------------------------------------------*/
104/*------------------------------ INCLUDES ----------------------------------*/
105/*--------------------------------------------------------------------------*/
106
107#include "ADS/Contract.h"
110
111#include <algorithm>
112#include <cstddef>
113#include <cstdint>
114#include <optional>
115#include <string>
116#include <string_view>
117#include <utility>
118#include <vector>
119
120/*--------------------------------------------------------------------------*/
121/*--------------------------- NAMESPACE ------------------------------------*/
122/*--------------------------------------------------------------------------*/
123
124namespace ADS
125{
126
130{
131 std::size_t distance = 0;
132 std::size_t length = 0;
133 std::optional< char > next;
135 friend bool operator==( const CopyPhrase & , const CopyPhrase & ) = default;
136 };
137
152[[nodiscard]] inline std::pair< std::size_t , std::size_t >
154
177[[nodiscard]] inline std::optional< std::size_t >
178repeatedSubstring( const SuffixArray & SA , std::size_t L , std::size_t C );
179
182[[nodiscard]] inline std::uint64_t
184
218[[nodiscard]] inline std::string
219longestCommonSubstring( const std::vector< std::string > & S , std::size_t k );
220
242[[nodiscard]] inline std::vector< std::pair< std::size_t , std::size_t > >
244
258[[nodiscard]] inline bool proximity( const SuffixArray & SA ,
259 std::string_view P , std::string_view Q ,
260 std::size_t k );
261
279[[nodiscard]] inline std::vector< std::size_t >
280kMismatches( std::string_view T , std::string_view P , std::size_t k );
281
306[[nodiscard]] inline std::vector< CopyPhrase >
307lz77ByTree( std::string_view T );
308
313[[nodiscard]] inline std::string
314decodeCopyPhrases( const std::vector< CopyPhrase > & Z );
315
316/*--------------------------------------------------------------------------*/
317
318} // end( namespace ADS )
319
320/*--------------------------------------------------------------------------*/
321/*-------------------------- IMPLEMENTATION --------------------------------*/
322/*--------------------------------------------------------------------------*/
323
324#include "ADS/string/impl/SuffixApplications.tpp"
325
326/*--------------------------------------------------------------------------*/
327
328#endif /* SuffixApplications.h included */
329
330/*--------------------------------------------------------------------------*/
331/*--------------------- End File SuffixApplications.h ----------------------*/
332/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The suffix array of a text of symbols, beyond the book: is the starting place of the -th smallest ...
The suffix tree of a text of symbols, beyond the book: the compact trie [see RadixTree in Trie....
the suffix array of a text with its , and arrays and the range minima of
Definition SuffixArray.h:497
the suffix tree of , its nodes in a vector, the root at 0
Definition SuffixTree.h:149
std::tuple< std::size_t, std::size_t, std::size_t > longestCommonSubstring(const S &P, const S &T)
the longest common substring: its length and where it ends in and , the first one found by rows of ;...
bool proximity(const SuffixArray &SA, std::string_view P, std::string_view Q, std::size_t k)
whether an occurrence of and one of start at most places apart
std::vector< std::size_t > kMismatches(std::string_view T, std::string_view P, std::size_t k)
the places where occurs in with at most mismatches
std::vector< std::pair< std::size_t, std::size_t > > maximalRepeats(const SuffixTree &ST)
the maximal repeats, as the place of an occurrence and the length
std::vector< CopyPhrase > lz77ByTree(std::string_view T)
the parsing of Ziv and Lempel of , the copies from the farthest occurrence, by the suffix tree
std::pair< std::size_t, std::size_t > longestRepeatedSubstring(const SuffixArray &SA)
the place and the length of a longest substring that occurs twice (0 and 0 if none)
std::string decodeCopyPhrases(const std::vector< CopyPhrase > &Z)
the text of a parsing, each phrase copying its symbols one at a time, so that a copy may overlap the ...
std::uint64_t distinctSubstrings(const SuffixArray &SA)
the number of distinct nonempty substrings,
std::optional< std::size_t > repeatedSubstring(const SuffixArray &SA, std::size_t L, std::size_t C)
the place of a substring of length that occurs at least times, if any
Definition ADT.h:96
a phrase of the parsing of Ziv and Lempel: copy length symbols from distance places back,...
Definition SuffixApplications.h:130
friend bool operator==(const CopyPhrase &, const CopyPhrase &)=default
the phrases are equal field by field
std::size_t length
the symbols copied
Definition SuffixApplications.h:132
std::optional< char > next
the symbol after the copy, none at the end
Definition SuffixApplications.h:133
std::size_t distance
how far back the copy starts
Definition SuffixApplications.h:131