kopia lustrzana https://gitlab.com/tomaszg/geostat
Change raw loop to std::algorithm copy
rodzic
397eaf415f
commit
add05af439
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
const int HIST_MAX = 20;
|
||||
|
||||
|
@ -41,8 +42,8 @@ void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string
|
|||
|
||||
for (auto el : cc)
|
||||
histogram[el.*ptr]++;
|
||||
for (auto el : histogram)
|
||||
pairs.push_back(el);
|
||||
std::copy(histogram.begin(), histogram.end(), std::back_inserter(pairs));
|
||||
|
||||
if (sort_by_val)
|
||||
sort(pairs.begin(), pairs.end(), [&](std::pair<std::string, int>& a, std::pair<std::string, int>& b) { return a.second > b.second; });
|
||||
else
|
||||
|
|
Ładowanie…
Reference in New Issue