1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #pragma once
#include <string>
#include <map>
#include <vector>
#include <algorithm>
struct data
{
int value;
std::string String;
};
struct header
{
int v;
std::string s;
};
class example
{
private:
header h_;
data d_;
std::map<header, std::vector<data>> container;
public:
example(const header& h, const data& d) : h_(h), d_(d) {}
void processing(const int v)
{
auto it = std::find_if(std::begin(container), std::end(container), [&](const header& h, const data& d) -> bool { return (h_.v == h.v && d_.value == d.value); });
if (it != std::end(container))
{
it->second.emplace_back(d_);
}
else
{
container[h_].emplace_back(d_);
}
}
}; |
Partager