diff options
Diffstat (limited to 'string/suffixAutomaton.cpp')
| -rw-r--r-- | string/suffixAutomaton.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/string/suffixAutomaton.cpp b/string/suffixAutomaton.cpp index 4e8abcf..7f4885c 100644 --- a/string/suffixAutomaton.cpp +++ b/string/suffixAutomaton.cpp @@ -15,8 +15,8 @@ struct SuffixAutomaton { for (auto c : s) extend(c); } - void extend(char c) { // Werte von c müssen bei 0 beginnen. - c -= 'a'; + void extend(char c) { + c -= 'a'; // Werte von c müssen bei 0 beginnen. int current = size++; states[current].length = states[last].length + 1; int pos = last; @@ -58,5 +58,15 @@ struct SuffixAutomaton { } return ii(bestpos - best + 1, best); } -}; + // Berechnet die Terminale des Automaten. + vector<int> calculateTerminals() { + vector<int> terminals; + int pos = last; + while (pos != -1) { + terminals.push_back(pos); + pos = states[pos].link; + } + return terminals; + } +}; |
