54 const std::string text =
"banana";
57 std::cout <<
"Naive Suffix Tree Example\n";
58 std::cout <<
"Text: " << text <<
"\n";
59 std::cout <<
"Node count: " << st.
node_count() <<
"\n\n";
61 const std::string pattern =
"ana";
62 const auto matches = st.
find_all(pattern);
64 std::cout <<
"Pattern: " << pattern <<
"\n";
65 std::cout <<
"Contains: " << (not matches.is_empty() ?
"yes" :
"no") <<
"\n";
66 std::cout <<
"Matches at positions: ";
67 for (
size_t i = 0; i < matches.size(); ++i)
68 std::cout << matches[i] << (i + 1 == matches.size() ?
"" :
" ");
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.
int main()
Example program demonstrating construction and queries on a Naive_Suffix_Tree for the string "banana"...