searching map by value
- by Mariusz Chw
I have 2 elements (for now) map:
#define IDI_OBJECT_5001 5001
#define IDI_OBJECT_5002 5002
/.../
ResourcesMap[IDI_OBJECT_5001] = "path_to_png_file1";
ResourcesMap[IDI_OBJECT_5002] = "path_to_png_file2";
I'm trying to implement method for searching this map. I'm passing string argument (file path) and method return int (key value of map)
int ResFiles::findResForBrew(string filePath)
{
string value = filePath;
int key = -1;
for (it = ResourcesMap.begin(); it != ResourcesMap.end(); ++it)
{
if (/*checking if it->second == value */)
{
key = it->first;
break;
}
}
return key;
}
How I could check when it-second- == value, and then return that key?
I would be grateful for some help. Thanks in advance.