What is the most efficient way to get lists (like vector ) of keys and values from unordered_map ?
For concreteness, suppose that the map in question is a unordered_map<string, double> . I would like to get the keys as vector<string> , and the values as vector<double> .
unordered_map<string, double> um; vector<string> vs = um.enum_keys(); vector<double> vd = um.enum_values();
I can just iterate over the map and collect the result, but is there still an effective method? It would be nice to have a method that also works for a regular card, since I can switch to this.
c ++ unordered-map vector c ++ 11 std
Faheem Mitha Dec 13 '11 at 3:28 2011-12-13 03:28
source share