|
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 558 of file Suffix_Structures.H.
|
inline |
Construct an empty suffix automaton (SAM) with only the root state.
| None. |
Definition at line 599 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 682 of file Suffix_Structures.H.
References clear(), 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 609 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 698 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 717 of file Suffix_Structures.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 626 of file Suffix_Structures.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), 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 738 of file Suffix_Structures.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::next(), and states_.
|
inlineprivate |
Traverse suffix links from last and mark all states as terminal.
| None. |
Definition at line 583 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 786 of file Suffix_Structures.H.
References states_.
Access the internal states array for testing/inspection.
| None. |
Definition at line 797 of file Suffix_Structures.H.
References states_.
|
private |
Definition at line 578 of file Suffix_Structures.H.
Referenced by clear(), extend(), and mark_terminals().
Definition at line 577 of file Suffix_Structures.H.
Referenced by clear(), contains(), distinct_substring_count(), extend(), longest_common_substring(), mark_terminals(), state_count(), and states().