|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Suffix automaton (SAM) over byte alphabet. More...
#include <Suffix_Structures.H>
Classes | |
| struct | State |
| One automaton state. More... | |
Public Member Functions | |
| Suffix_Automaton () | |
| Construct an empty suffix automaton (SAM) with only the root state. | |
| void | clear () |
| Reset the automaton to its initial empty state (root only). | |
| void | extend (const char ch) |
| Extend the SAM with a single character. | |
| void | build (const std::string_view text) |
| Build the SAM from an entire string. | |
| bool | contains (const std::string_view pattern) const |
Return true if pattern is a substring of the built text. | |
| size_t | distinct_substring_count () const |
| Count the number of distinct substrings in the built text. | |
| std::string | longest_common_substring (const std::string_view other) const |
Find the longest common substring between the built SAM text and other. | |
| size_t | state_count () const noexcept |
| Return the number of states in the SAM. | |
| const Array< State > & | states () const noexcept |
| Access the internal states array for testing/inspection. | |
Private Member Functions | |
| void | mark_terminals () |
| Traverse suffix links from last and mark all states as terminal. | |
Private Attributes | |
| Array< State > | states_ |
| int | last_ = 0 |
Suffix automaton (SAM) over byte alphabet.
Supports substring checks, distinct substring counting, and longest common substring against another string.
Definition at line 586 of file Suffix_Structures.H.
|
inline |
Construct an empty suffix automaton (SAM) with only the root state.
| None. |
Definition at line 627 of file Suffix_Structures.H.
References clear().
Build the SAM from an entire string.
| [in] | text | The input string to process. |
| None. |
Definition at line 711 of file Suffix_Structures.H.
References clear(), Aleph::divide_and_conquer_partition_dp(), extend(), and mark_terminals().
Referenced by Aleph::longest_common_substring_sam(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inline |
Reset the automaton to its initial empty state (root only).
| None. |
Definition at line 637 of file Suffix_Structures.H.
References last_, and states_.
Referenced by Suffix_Automaton(), and build().
Return true if pattern is a substring of the built text.
| [in] | pattern | The substring pattern to search for. |
pattern, false otherwise. | None. |
Definition at line 727 of file Suffix_Structures.H.
References Aleph::next(), and states_.
|
inline |
Count the number of distinct substrings in the built text.
| None. |
Definition at line 746 of file Suffix_Structures.H.
References Aleph::divide_and_conquer_partition_dp(), Aleph::Suffix_Automaton::State::len, Aleph::Suffix_Automaton::State::link, and states_.
Extend the SAM with a single character.
| [in] | ch | The character to append to the current text representation. |
| None. |
Definition at line 654 of file Suffix_Structures.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), last_, Aleph::Suffix_Automaton::State::len, Aleph::next(), and states_.
Referenced by build().
|
inline |
Find the longest common substring between the built SAM text and other.
| [in] | other | String to compare against the built SAM text. |
| None. |
Definition at line 767 of file Suffix_Structures.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), Aleph::next(), and states_.
|
inlineprivate |
Traverse suffix links from last and mark all states as terminal.
| None. |
Definition at line 611 of file Suffix_Structures.H.
References last_, and states_.
Referenced by build().
|
inlinenoexcept |
Return the number of states in the SAM.
| None. |
Definition at line 815 of file Suffix_Structures.H.
References states_.
Access the internal states array for testing/inspection.
| None. |
Definition at line 826 of file Suffix_Structures.H.
References states_.
|
private |
Definition at line 606 of file Suffix_Structures.H.
Referenced by clear(), extend(), and mark_terminals().
Definition at line 605 of file Suffix_Structures.H.
Referenced by clear(), contains(), distinct_substring_count(), extend(), longest_common_substring(), mark_terminals(), state_count(), and states().