I met a question in my work
There is an unordered_map on vector<int> in my c++ class
like this unordered_map < int, vector<int> >
so how could I initialize the nested container so that when I insert a key to the hash table and the value(vector) will be ten zero ?
You can use list initialization:
std::unordered_map<int, std::vector<int>> m
{ { 2, std::vector<int>(10, 0) }
, { 5, std::vector<int>(10, 0) }
, { 6, std::vector<int>(10, 0) }
, { 9, std::vector<int>(10, 0) }
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With