Skip to content

Commit 8735283

Browse files
author
Cameron Custer
committed
use c++20 ranges where shorter
1 parent 3251c26 commit 8735283

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

library/data_structures_[l,r)/uncommon/priority_queue_of_updates.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ template<class DS, class... ARGS> struct pq_updates {
4343
remove_if(idx + all(upd_st), [&](auto& curr) {
4444
return curr.second->first >= lowest_pri;
4545
});
46-
reverse_copy(all(extra), it);
46+
ranges::reverse_copy(extra, it);
4747
rep(i, idx, sz(upd_st)) ds.undo();
4848
upd_st.pop_back();
4949
mp.erase(prev(end(mp)));

library/graphs/mst.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ pair<ll, vi> mst(const vector<array<int, 3>>& w_eds,
1111
int n) {
1212
vi order(sz(w_eds));
1313
iota(all(order), 0);
14-
ranges::sort(order, [&](int i, int j) {
15-
return w_eds[i][2] < w_eds[j][2];
16-
});
14+
ranges::sort(order, {},
15+
[&](int i) { return w_eds[i][2]; });
1716
DSU dsu(n);
1817
vi ids;
1918
ll cost = 0;

library/strings/suffix_array/find/find_string_bs_fast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ match find_str_fast(const T& t) {
1616
return lexicographical_compare(it_s, end(s), it_t,
1717
end(t));
1818
};
19-
int sa_le = lower_bound(all(sa), 0, cmp) - begin(sa),
19+
int sa_le = ranges::lower_bound(sa, 0, cmp) - begin(sa),
2020
sa_ri = sa_le;
2121
if (s_len == sz(t))
2222
sa_ri = lower_bound(sa_le + all(sa), 0,

library/strings/wildcard_pattern_matching.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ vector<bool> wildcard_pattern_matching(const vl& s,
2525
int n = sz(s), m = sz(t);
2626
auto s_pws = make_powers(s);
2727
auto t_pws = make_powers(t);
28-
for (auto& t_pw : t_pws) reverse(all(t_pw));
28+
for (auto& t_pw : t_pws) ranges::reverse(t_pw);
2929
vector<vl> res(3);
3030
rep(pw_hay, 0, 3)
3131
res[pw_hay] = conv(s_pws[pw_hay], t_pws[2 - pw_hay]);

0 commit comments

Comments
 (0)