From fc6da254c57a94cda4c8f61b8d9daa507dcdfdda Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Wed, 20 Nov 2024 01:54:02 +0100 Subject: rename sparse table query function: queryIdempotent -> query --- content/datastructures/datastructures.tex | 2 +- content/datastructures/sparseTable.cpp | 2 +- content/graph/LCA_sparse.cpp | 2 +- test/datastructures/sparseTable.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/datastructures/datastructures.tex b/content/datastructures/datastructures.tex index 0495543..c4bd312 100644 --- a/content/datastructures/datastructures.tex +++ b/content/datastructures/datastructures.tex @@ -58,7 +58,7 @@ \begin{algorithm}{Range Minimum Query} \begin{methods} \method{init}{baut Struktur auf}{n\*\log(n)} - \method{queryIdempotent}{Index des Minimums in $[l, r)$}{1} + \method{query}{Index des Minimums in $[l, r)$}{1} \end{methods} \begin{itemize} \item \code{better}-Funktion muss idempotent sein! diff --git a/content/datastructures/sparseTable.cpp b/content/datastructures/sparseTable.cpp index 44989ab..5455ef5 100644 --- a/content/datastructures/sparseTable.cpp +++ b/content/datastructures/sparseTable.cpp @@ -16,7 +16,7 @@ struct SparseTable { st[j + 1][i] = better(st[j][i] , st[j][i + (1 << j)]); }}} - int queryIdempotent(int l, int r) { + int query(int l, int r) { if (r <= l) return -1; int j = __lg(r - l); //31 - builtin_clz(r - l); return better(st[j][l] , st[j][r - (1 << j)]); diff --git a/content/graph/LCA_sparse.cpp b/content/graph/LCA_sparse.cpp index 22a9082..1da8876 100644 --- a/content/graph/LCA_sparse.cpp +++ b/content/graph/LCA_sparse.cpp @@ -25,7 +25,7 @@ struct LCA { int getLCA(int u, int v) { if (first[u] > first[v]) swap(u, v); - return visited[st.queryIdempotent(first[u], first[v] + 1)]; + return visited[st.query(first[u], first[v] + 1)]; } ll getDepth(int v) { return depth[first[v]]; } diff --git a/test/datastructures/sparseTable.cpp b/test/datastructures/sparseTable.cpp index 2cfded9..843e962 100644 --- a/test/datastructures/sparseTable.cpp +++ b/test/datastructures/sparseTable.cpp @@ -14,7 +14,7 @@ void stress_test() { int l = Random::integer(0, n+1); int r = Random::integer(0, n+1); - ll got = st.queryIdempotent(l, r); + ll got = st.query(l, r); ll expected = r <= l ? -1 : l; for (int j = l; j < r; j++) { if (naive[j] < naive[expected]) expected = j; @@ -38,7 +38,7 @@ void performance_test() { auto [l, r] = Random::pair(0, N+1); t.start(); - hash += st.queryIdempotent(l, r); + hash += st.query(l, r); t.stop(); } if (t.time > 500) cerr << "too slow: " << t.time << FAIL; -- cgit v1.2.3