![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in aho-corasick.hpp
.
This namespace contains various helper functions for the class AhoCorasick. These functions could be functions of AhoCorasick but they only use public member functions of AhoCorasick, and so they are declared as free functions instead.
Typedefs | |
using | index_type = AhoCorasick::index_type |
Alias for the index of a node in the trie. | |
Functions | |
template<typename Word> | |
index_type | add_word (AhoCorasick &ac, Word const &w) |
Add a word to the trie of ac . | |
template<typename Word> | |
index_type | add_word_no_checks (AhoCorasick &ac, Word const &w) |
Add a word to the trie of ac . | |
Dot | dot (AhoCorasick &ac) |
Construct a dot object of ac . | |
template<typename Word> | |
index_type | rm_word (AhoCorasick &ac, Word const &w) |
Remove a word from the trie of ac . | |
template<typename Word> | |
index_type | rm_word_no_checks (AhoCorasick &ac, Word const &w) |
Remove a word from the trie of ac . | |
template<typename Iterator> | |
index_type | traverse_word (AhoCorasick const &ac, index_type start, Iterator first, Iterator last) |
Traverse the trie of ac using suffix links where necessary. | |
template<typename Word> | |
index_type | traverse_word (AhoCorasick const &ac, index_type start, Word const &w) |
Traverse the trie of ac using suffix links where necessary. | |
template<typename Iterator> | |
index_type | traverse_word (AhoCorasick const &ac, Iterator first, Iterator last) |
Traverse the trie of ac from the root using suffix links where necessary. | |
template<typename Word> | |
index_type | traverse_word (AhoCorasick const &ac, Word const &w) |
Traverse the trie of ac from the root using suffix links where necessary. | |
template<typename Iterator> | |
index_type | traverse_word_no_checks (AhoCorasick const &ac, index_type start, Iterator first, Iterator last) |
Traverse the trie of ac using suffix links where necessary. | |
index_type | traverse_word_no_checks (AhoCorasick const &ac, index_type start, word_type const &w) |
Traverse the trie of ac using suffix links where necessary. | |
index_type add_word | ( | AhoCorasick & | ac, |
Word const & | w ) |
This function performs the same as ac.add_word(w.begin(), w.end())
.
Word | the type of the 2nd parameter w . |
ac | AhoCorasick object to add the word to. |
w | the word to add. |
ac
.LibsemigroupsException | if the word w corresponds to an existing terminal node in the trie. |
w
.index_type add_word_no_checks | ( | AhoCorasick & | ac, |
Word const & | w ) |
This function performs the same as ac.add_word_no_checks(w.begin(), w.end())
.
Word | the type of the 2nd parameter w . |
ac | AhoCorasick object to add the word to. |
w | the word to add. |
ac
.w
.
|
nodiscard |
Construct a Dot object representing the trie of ac
with suffix links.
index_type rm_word | ( | AhoCorasick & | ac, |
Word const & | w ) |
This function performs the same as ac.rm_word(w.begin(), w.end())
.
Word | the type of the 2nd parameter w . |
ac | AhoCorasick object to remove the word from. |
w | the word to remove. |
w
.LibsemigroupsException | if the word w does not correspond to an existing terminal node in the trie. |
w
.index_type rm_word_no_checks | ( | AhoCorasick & | ac, |
Word const & | w ) |
This function performs the same as ac.rm_word_no_checks(w.begin(), w.end())
.
Word | the type of the 2nd parameter w . |
ac | AhoCorasick object to remove the word from. |
w | the word to remove. |
w
.w
.
|
nodiscard |
After validating start
with respect to ac
, this function performs the same as traverse_word_no_checks(ac, start, first, last)
.
LibsemigroupsException | if ac.throw_if_node_index_not_active(start) throws. |
|
inlinenodiscard |
This function performs the same as traverse_word(ac, start, w.cbegin(), w.cend())
.
|
nodiscard |
This function performs the same as traverse_word_no_checks(ac, AhoCorasick::root, first, last)
.
_no_checks
suffix here as AhoCorasick::root is always a valid node of a trie, and therefore no checks are needed.
|
nodiscard |
This function performs the same as traverse_word_no_checks(ac, AhoCorasick::root, w.cbegin(), w.end())
.
_no_checks
suffix here as AhoCorasick::root is always a valid node of a trie, and therefore no checks are needed.
|
nodiscard |
This function traverses the trie of ac
, starting at the node with index start
, and traversing using the letters in the word corresponding to first
and last
.
Iterator | the type of the 2nd and 3rd parameters. |
ac | AhoCorasick object to traverse. |
start | the index of the node to first traverse from. |
first | iterator pointing to the first letter of the word to traverse. |
last | one beyond the last letter of the word to traverse. |
index_type
.start
is greater than the number of nodes that have ever been created, then bad things will happen.
|
inlinenodiscard |
This function performs the same as traverse_word_no_checks(ac, start, w.cbegin(), w.cend())
.