Skip to content

Commit a3cd552

Browse files
committed
Small code style fix
1 parent 573ac84 commit a3cd552

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

etc/compression.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
using namespace std;
44

5-
6-
// compresses positions [0,n) to values [pos, n+pos]
5+
// compresses values in positions [ini, fim) to [pos, n+pos]
76
template <typename Iter>
87
void compress(Iter ini, Iter fim, int pos=1)
98
{
109
using T = typename decay<decltype(*ini)>::type;
1110

12-
vector<T> vv(fim-ini);
13-
copy(ini, fim, vv.begin());
11+
vector<T> vv(ini, fim);
1412
sort(vv.begin(), vv.end());
1513
vv.erase(unique(vv.begin(), vv.end()), vv.end());
14+
1615
for_each(ini, fim, [&] (T& x) {
17-
x = lower_bound(vv.begin(), vv.end(), x)-vv.begin() + pos;
16+
x = lower_bound(vv.begin(), vv.end(), x) - vv.begin() + pos;
1817
});
1918
}
2019

@@ -23,7 +22,7 @@ vector<int> v{1000, 2000, 5000, 3000};
2322

2423
int main()
2524
{
26-
compress(va+1, va+5, 1);
25+
compress(va+1, va+5);
2726
compress(v.begin(), v.end(), 0);
2827

2928
for (int i = 1; i <= 4; i++)

0 commit comments

Comments
 (0)