Can I use following syntax:
std::map> mAllData;
Where Key Value(int) will be ID of data, and said data could ha
std::map> my_map;
my_map[10].push_back(10000);
my_map[10].push_back(20000);
my_map[10].push_back(40000);
Your compiler may not support the two closing angle brackets being right next to each other yet, so you might need std::map
.
With C++11 my_map
can be initialized more efficiently:
std::map> my_map {{10, {10000,20000,40000}}};
Also, if you just want a way to store multiple values per key, you can use std::multimap.
std::multimap my_map;
my_map.insert(std::make_pair(10,10000));
my_map.insert(std::make_pair(10,20000));
And in C++11 this can be written:
std::multimap my_map {{10,10000},{10,20000}};