mardi 27 janvier 2015

How to find out under which key of a map a given value is stored?


std::map<std::string, std::vector<std::string>> myMap


How can we find out under which key of the myMap the string '55' is stored?



std::vector<string> vec1 = {"11", "22", "33"};
std::vector<string> vec2 = {"44", "55"};
std::vector<string> vec3 = {};

std::string key1 = "1";
std::string key2 = "2";
std::string key3 = "3";

myMap.insert(std::make_pair(key1, vec1));
myMap.insert(std::make_pair(key2, vec2));
myMap.insert(std::make_pair(key3, vec3));

Aucun commentaire:

Enregistrer un commentaire