Skip to content

Commit 73346b0

Browse files
committed
pass lambdas not by const reference
1 parent e3fd029 commit 73346b0

11 files changed

Lines changed: 17 additions & 20 deletions

File tree

library/data_structures_[l,r)/bit_uncommon/walk_lambda.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void walk(const auto& f) {
1+
void walk(auto f) {
22
ll sum = 0;
33
for (int i = bit_floor(size(s)), r = 0; i; i /= 2)
44
if (r + i <= sz(s) && f(r + i, sum + s[r + i - 1]))

library/data_structures_[l,r)/seg_tree_uncommon/find_first.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,20 @@
2525
//! such element exists then `r` is returned
2626
//! @time O(log(n))
2727
//! @space O(log(n)) for recursion stack
28-
int find_first(int l, int r, const auto& f) {
28+
int find_first(int l, int r, auto f) {
2929
return find_first_in_range(l, r, f, 0, n, 1);
3030
}
3131
//! invariant: f(tree[v], tl, tr) is 1
32-
int find_first_in_subtree(const auto& f, int tl, int tr,
33-
int v) {
32+
int find_first_in_subtree(auto f, int tl, int tr, int v) {
3433
if (v >= n) return tl;
3534
int tm = split(tl, tr);
3635
push(tl, tm, tr, v);
3736
if (f(tree[2 * v], tl, tm))
3837
return find_first_in_subtree(f, tl, tm, 2 * v);
3938
return find_first_in_subtree(f, tm, tr, 2 * v + 1);
4039
}
41-
int find_first_in_range(int l, int r, const auto& f,
42-
int tl, int tr, int v) {
40+
int find_first_in_range(int l, int r, auto f, int tl,
41+
int tr, int v) {
4342
if (r <= tl || tr <= l) return r;
4443
if (l <= tl && tr <= r)
4544
return f(tree[v], tl, tr)

library/data_structures_[l,r)/seg_tree_uncommon/find_last.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@
2525
//! such element exists then (l - 1) is returned
2626
//! @time O(log(n))
2727
//! @space O(log(n)) for recursion stack
28-
int find_last(int l, int r, const auto& f) {
28+
int find_last(int l, int r, auto f) {
2929
return find_last_in_range(l, r, f, 0, n, 1);
3030
}
3131
//! invariant: f(tree[v], tl, tr) is 1
32-
int find_last_in_subtree(const auto& f, int tl, int tr,
33-
int v) {
32+
int find_last_in_subtree(auto f, int tl, int tr, int v) {
3433
if (v >= n) return tl;
3534
int tm = split(tl, tr);
3635
push(tl, tm, tr, v);
3736
if (f(tree[2 * v + 1], tm, tr))
3837
return find_last_in_subtree(f, tm, tr, 2 * v + 1);
3938
return find_last_in_subtree(f, tl, tm, 2 * v);
4039
}
41-
int find_last_in_range(int l, int r, const auto& f, int tl,
40+
int find_last_in_range(int l, int r, auto f, int tl,
4241
int tr, int v) {
4342
if (r <= tl || tr <= l) return l - 1;
4443
if (l <= tl && tr <= r)

library/data_structures_[l,r)/seg_tree_uncommon/min_left.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void min_left(int l, int r, const auto& f) {
1+
void min_left(int l, int r, auto f) {
22
for (T x = unit; l < r;) {
33
int u = r + n, v = __lg(min(u & -u, r - l)),
44
m = r - (1 << v);

library/data_structures_[l,r]/bit_uncommon/walk_lambda.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void walk(const auto& f) {
1+
void walk(auto f) {
22
ll sum = 0;
33
for (int i = bit_floor(size(s)), r = 0; i; i /= 2)
44
if (r + i <= sz(s) && f(r + i - 1, sum + s[r + i - 1]))

library/data_structures_[l,r]/seg_tree_uncommon/max_right.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
void max_right(int l, int r, const auto& f) {
1+
void max_right(int l, int r, auto f) {
22
if (T x = s[l + n]; f(l, x))
33
for (l++; l <= r;) {
44
int u = l + n, v = __lg(min(u & -u, r - l + 1)),

library/data_structures_[l,r]/seg_tree_uncommon/min_left.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
int min_left(int l, int r, const auto& f) {
1+
int min_left(int l, int r, auto f) {
22
if (T x = s[r + n]; f(r, x))
33
for (r--; l <= r;) {
44
int u = r + 1 + n, v = __lg(min(u & -u, r - l + 1)),

library/dsu/range_parallel_dsu.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
struct rp_dsu {
99
vector<DSU> dsus;
1010
rp_dsu(int n): dsus(bit_width(n + 0u), DSU(n)) {}
11-
void join(int u, int v, int len, const auto& f) {
11+
void join(int u, int v, int len, auto f) {
1212
int i = __lg(len);
1313
join(u, v, f, i);
1414
join(u + len - (1 << i), v + len - (1 << i), f, i);
1515
}
16-
void join(int u, int v, const auto& f, int i) {
16+
void join(int u, int v, auto f, int i) {
1717
if (!dsus[i].join(u, v)) return;
1818
if (i == 0) return f(u, v);
1919
i--;

library/monotonic_stack/monotonic_stack.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! a[le[i]] < a[i]
88
//! @time O(n)
99
//! @space O(n)
10-
vi mono_st(const auto& a, const auto& cmp) {
10+
vi mono_st(const auto& a, auto cmp) {
1111
vi l(sz(a));
1212
rep(i, 0, sz(a)) for (l[i] = i - 1;
1313
l[i] >= 0 && !cmp(a[l[i]], a[i]);) l[i] = l[l[i]];

library/trees/centroid_decomp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! @endcode
66
//! @time O(n log n)
77
//! @space O(n)
8-
void centroid(auto& adj, const auto& f) {
8+
void centroid(auto& adj, auto f) {
99
vi siz(sz(adj));
1010
auto calc_sz = [&](auto&& self, int u, int p) -> void {
1111
siz[u] = 1;

0 commit comments

Comments
 (0)