# include <iostream>
# include <string>
{
const std::string text = "banana";
std::cout << "Naive Suffix Tree Example\n";
std::cout << "Text: " << text << "\n";
std::cout <<
"Node count: " << st.
node_count() <<
"\n\n";
const std::string pattern = "ana";
const auto matches = st.
find_all(pattern);
std::cout << "Pattern: " << pattern << "\n";
std::cout << "Contains: " << (not matches.is_empty() ? "yes" : "no") << "\n";
std::cout << "Matches at positions: ";
for (size_t i = 0; i < matches.size(); ++i)
std::cout << matches[i] << (i + 1 == matches.size() ? "" : " ");
std::cout << "\n";
return 0;
}
Suffix structures: suffix array/LCP, suffix tree, suffix automaton.
Naive compressed suffix tree (didactic implementation).
Array< size_t > find_all(const std::string_view pattern) const
Return all occurrences of a pattern.
size_t node_count() const noexcept
Return the number of nodes in the tree.
Main namespace for Aleph-w library functions.