diff options
| author | MZuenni <michi.zuendorf@gmail.com> | 2023-03-01 11:36:26 +0100 |
|---|---|---|
| committer | MZuenni <michi.zuendorf@gmail.com> | 2023-03-01 11:36:26 +0100 |
| commit | 12afe719ce268bb10aa93a910079a44eb08999b8 (patch) | |
| tree | 0937a117287eebe3942e0506d27143eff4980d09 /string | |
| parent | ad8456f7c5d44d3c647b3a368050a5d2f39ae3c3 (diff) | |
removed trailing whitespaces and use more structured bindings
Diffstat (limited to 'string')
| -rw-r--r-- | string/ahoCorasick.cpp | 4 | ||||
| -rw-r--r-- | string/duval.cpp | 6 | ||||
| -rw-r--r-- | string/lyndon.cpp | 2 | ||||
| -rw-r--r-- | string/rollingHashCf.cpp | 2 | ||||
| -rw-r--r-- | string/string.tex | 2 | ||||
| -rw-r--r-- | string/suffixArray.cpp | 4 | ||||
| -rw-r--r-- | string/suffixAutomaton.cpp | 2 |
7 files changed, 11 insertions, 11 deletions
diff --git a/string/ahoCorasick.cpp b/string/ahoCorasick.cpp index c83f9c3..9ffa6c9 100644 --- a/string/ahoCorasick.cpp +++ b/string/ahoCorasick.cpp @@ -4,7 +4,7 @@ struct AhoCorasick { struct vert { int suffix, exit, character, parent; vector<int> nxt, patterns; - vert(int c, int p) : suffix(-1), exit(-1), + vert(int c, int p) : suffix(-1), exit(-1), character(c), nxt(ALPHABET_SIZE, -1), parent(p) {} }; vector<vert> aho; @@ -28,7 +28,7 @@ struct AhoCorasick { int getSuffix(int v) { if (aho[v].suffix == -1) { if (v == 0 || aho[v].parent == 0) aho[v].suffix = 0; - else aho[v].suffix = go(getSuffix(aho[v].parent), + else aho[v].suffix = go(getSuffix(aho[v].parent), aho[v].character); } return aho[v].suffix; diff --git a/string/duval.cpp b/string/duval.cpp index 6d80e95..bf36cce 100644 --- a/string/duval.cpp +++ b/string/duval.cpp @@ -15,7 +15,7 @@ vector<pair<int, int>> duval(const string& s) { int minrotation(const string& s) { auto parts = duval(s+s); - for (auto e : parts) { - if (e.first < sz(s) && e.second >= sz(s)) { - return e.first; + for (auto [l, r] : parts) { + if (l < sz(s) && r >= sz(s)) { + return l; }}} diff --git a/string/lyndon.cpp b/string/lyndon.cpp index 6a131a5..858c3db 100644 --- a/string/lyndon.cpp +++ b/string/lyndon.cpp @@ -1,5 +1,5 @@ bool next(string& s, int n, char mi = '0', char ma = '1') { - for (ll i = sz(s), j = sz(s); i < n; i++) + for (int i = sz(s), j = sz(s); i < n; i++) s.push_back(s[i % j]); while(!s.empty() && s.back() == ma) s.pop_back(); if (s.empty()) { diff --git a/string/rollingHashCf.cpp b/string/rollingHashCf.cpp index d1b8893..9608aff 100644 --- a/string/rollingHashCf.cpp +++ b/string/rollingHashCf.cpp @@ -4,7 +4,7 @@ struct Hasher { vector<ll> power = {1}, pref = {0}; ll m, q; char c; - Hasher(const string& s, ll m, ll q, char c) : + Hasher(const string& s, ll m, ll q, char c) : m(m), q(q), c(c) { for (char x : s) { power.push_back(power.back() * q % m); diff --git a/string/string.tex b/string/string.tex index 6b83e2c..a09d7f8 100644 --- a/string/string.tex +++ b/string/string.tex @@ -54,7 +54,7 @@ \begin{enumerate} \item mit \code{addString(pattern, idx);} Patterns hinzufügen. \item mit \code{state = go(state, idx)} in nächsten Zustand wechseln. - \item mit \code{state = getExit(state)} den exit Kanten folgen bis \code{state == 0} + \item mit \code{state = getExit(state)} den exit Kanten folgen bis \code{state == 0} \item dabei mit \code{aho[state].patterns} die Matches zählen \end{enumerate} \sourcecode{string/ahoCorasick.cpp} diff --git a/string/suffixArray.cpp b/string/suffixArray.cpp index df6259a..720148c 100644 --- a/string/suffixArray.cpp +++ b/string/suffixArray.cpp @@ -9,11 +9,11 @@ struct SuffixArray { for (int i = 0; i < n; i++) P[0][i] = s[i]; for (step = 1, count = 1; count < n; step++, count *= 2) { for (int i = 0; i < n; i++) - L[i] = {{P[step-1][i], + L[i] = {{P[step-1][i], i+count < n ? P[step-1][i+count] : -1}, i}; sort(all(L)); for (int i = 0; i < n; i++) { - P[step][L[i].second] = + P[step][L[i].second] = i > 0 && L[i].first == L[i-1].first ? P[step][L[i-1].second] : i; }} diff --git a/string/suffixAutomaton.cpp b/string/suffixAutomaton.cpp index 4d05b6e..c6205da 100644 --- a/string/suffixAutomaton.cpp +++ b/string/suffixAutomaton.cpp @@ -2,7 +2,7 @@ constexpr char MIN_CHAR = 'a'; constexpr ll ALPHABET_SIZE = 26; struct SuffixAutomaton { struct State { - int length, link; + int length, link; vector<int> next; State() : next(ALPHABET_SIZE) {} }; |
