37# include <gtest/gtest.h>
59 const std::string
text =
"the quick brown fox jumps over the lazy dog fox";
60 const std::string pattern =
"fox";
71 for (
size_t i = 0; i <
kmp.size(); ++i)
81 const std::string
text =
"ababababab";
82 const std::string pattern =
"abab";
101 const std::string
text =
"abracadabra";
102 const std::string pattern =
"abra";
117 const std::string
text =
"mississippi";
123 const char *
patterns[] = {
"issi",
"miss",
"pi",
"ppi",
"xyz",
"sip",
""};
126 <<
"Disagreement on pattern: \"" << p <<
"\"";
131 const std::string a =
"xabxac";
132 const std::string b =
"abcabxabcd";
Umbrella header for classical string algorithms in Aleph-w.
Aho-Corasick multi-pattern automaton.
size_t add_pattern(std::string pattern)
Add one pattern to the automaton.
Naive compressed suffix tree (didactic implementation).
Array< size_t > find_all(const std::string_view pattern) const
Return all occurrences of a pattern.
bool contains(const std::string_view pattern) const
Return true if the pattern appears in the text.
Suffix automaton (SAM) over byte alphabet.
void build(const std::string_view text)
Build the SAM from an entire string.
Main namespace for Aleph-w library functions.
Array< size_t > z_search(const std::string_view text, const std::string_view pattern)
Find all occurrences of a pattern using the Z-algorithm.
Array< size_t > rabin_karp_search(const std::string_view text, const std::string_view pattern, const uint64_t base=911382323ull)
Find all occurrences using Rabin-Karp with rolling hash.
size_t size(Node *root) noexcept
size_t edit_distance(const std::string_view a, const std::string_view b)
Alias for Levenshtein distance.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::string longest_common_substring_sam(const std::string_view a, const std::string_view b)
Convenience function: LCS via suffix automaton.
Longest_Common_Substring_Result longest_common_substring(const std::string_view a, const std::string_view b)
Compute the longest common substring (contiguous) between two strings.
std::string longest_palindromic_substring(const std::string_view text)
Convenience wrapper returning only the longest palindromic substring.
Array< size_t > kmp_search(const std::string_view text, const std::string_view pattern)
Find all occurrences of a pattern using KMP.
Array< size_t > boyer_moore_horspool_search(const std::string_view text, const std::string_view pattern)
Find all occurrences using Boyer-Moore-Horspool.
Array< size_t > suffix_array(const std::string_view text)
Build suffix array with doubling algorithm.