Change raw loop to std::algorithm copy

sql-rework
Tomasz Golinski 2020-02-16 20:17:06 +01:00
rodzic 397eaf415f
commit add05af439
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -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