Skip to content

Commit 4074383

Browse files
authored
Refactor lazy segment tree methods for clarity
1 parent 9db9cd7 commit 4074383

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

library/data_structures_[l,r)/lazy_seg_tree.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ struct seg_tree {
2323
}
2424
}
2525
void update(int l, int r, ll change) { // [l, r)
26-
update_impl(l, r, change, 0, n, 1);
26+
update(l, r, change, 0, n, 1);
2727
}
28-
void update_impl(int l, int r, ll change, int tl, int tr,
28+
void update(int l, int r, ll change, int tl, int tr,
2929
int v) {
3030
if (r <= tl || tr <= l) return;
3131
if (l <= tl && tr <= r)
3232
return apply(change, tl, tr, v);
3333
int tm = split(tl, tr);
3434
push(tl, tm, tr, v);
35-
update_impl(l, r, change, tl, tm, 2 * v);
36-
update_impl(l, r, change, tm, tr, 2 * v + 1);
35+
update(l, r, change, tl, tm, 2 * v);
36+
update(l, r, change, tm, tr, 2 * v + 1);
3737
tree[v] = op(tree[2 * v], tree[2 * v + 1]);
3838
}
3939
ll query(int l, int r) { // [l, r)
40-
return query_impl(l, r, 0, n, 1);
40+
return query(l, r, 0, n, 1);
4141
}
42-
ll query_impl(int l, int r, int tl, int tr, int v) {
42+
ll query(int l, int r, int tl, int tr, int v) {
4343
if (r <= tl || tr <= l) return 0;
4444
if (l <= tl && tr <= r) return tree[v];
4545
int tm = split(tl, tr);
4646
push(tl, tm, tr, v);
47-
return op(query_impl(l, r, tl, tm, 2 * v),
48-
query_impl(l, r, tm, tr, 2 * v + 1));
47+
return op(query(l, r, tl, tm, 2 * v),
48+
query(l, r, tm, tr, 2 * v + 1));
4949
}
5050
#include "seg_tree_uncommon/find_first.hpp"
5151
#include "seg_tree_uncommon/find_last.hpp"

0 commit comments

Comments
 (0)