Skip to content

Commit b791873

Browse files
authored
Refactor update and query methods in lazy_seg_tree
1 parent 00695a4 commit b791873

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@ struct seg_tree {
2222
lazy[v] = 0;
2323
}
2424
}
25-
void update(int l, int r, ll change) { // [l, r]
26-
update_impl(l, r, change, 0, n - 1, 1);
25+
void update(int l, int r, ll change) {
26+
update(l, r, change, 0, n - 1, 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 + 1, tr, 2 * v + 1);
35+
update(l, r, change, tl, tm, 2 * v);
36+
update(l, r, change, tm + 1, tr, 2 * v + 1);
3737
tree[v] = op(tree[2 * v], tree[2 * v + 1]);
3838
}
39-
ll query(int l, int r) { // [l, r]
40-
return query_impl(l, r, 0, n - 1, 1);
39+
ll query(int l, int r) {
40+
return query(l, r, 0, n - 1, 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 + 1, tr, 2 * v + 1));
47+
return op(query(l, r, tl, tm, 2 * v),
48+
query(l, r, tm + 1, tr, 2 * v + 1));
4949
}
5050
};

0 commit comments

Comments
 (0)