Commit a76ca2f
prefer ranges algorithms over iterator-pair std calls (library + tests) (#244)
* use ranges::iota over std::iota for full-range calls
Convert the full-range std::iota(begin, end, v) calls to
ranges::iota(range, v). This favors the ranges algorithms already used
throughout the library and removes an all(...) macro expansion on main.
Partial-range calls (e.g. iterator sub-ranges) and std::partial_sum are
left as-is: partial_sum has no ranges equivalent, and partial ranges read
more clearly with explicit iterators.
* use ranges::unique and ranges::partition for full-range calls
Convert the remaining full-range std algorithm calls to their ranges::
equivalents:
- virtual_tree: unique(all(subset)) -> begin(ranges::unique(subset))
- edge_cd: partition(all(g[u]), ...) -> begin(ranges::partition(g[u], ...))
ranges::unique / ranges::partition return a subrange, so begin(...) yields
the iterator the erase / offset logic needs.
Partial-range calls (iterator sub-ranges) and std::partial_sum are still
left as-is: partial_sum has no ranges equivalent, and partial ranges read
more clearly with explicit iterators.
* use ranges algorithms in tests for full-range std calls
Apply the same "prefer ranges" convention to the test suite:
- iota(all(x), v) -> ranges::iota(x, v)
- unique(all(x)) -> begin(ranges::unique(x)) (erase / == end idiom)
- remove_if(all(x), pred) -> begin(ranges::remove_if(x, pred)) (erase idiom)
- next_permutation(all(x)) -> ranges::next_permutation(x).found
accumulate(all(x), ...) is left as-is: there is no ranges::accumulate in
C++23 (ranges::fold_left would change the idiom), matching how partial_sum
is left in the library.
* [auto-verifier] verify commit 69ac3da
* [auto-verifier] verify commit e6325f1
---------
Co-authored-by: GitHub <noreply@github.com>1 parent 7bf45aa commit a76ca2f
23 files changed
Lines changed: 73 additions & 73 deletions
File tree
- .verify-helper
- library
- dsu
- graphs
- strongly_connected_components
- uncommon
- math/prime_sieve
- strings
- longest_common_subsequence
- manacher
- suffix_array
- trees
- extra_members
- tests/library_checker_aizu_tests
- data_structures
- graphs
- handmade_tests
- strings
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
0 commit comments