searching map by value
Posted
by
Mariusz Chw
on Stack Overflow
See other posts from Stack Overflow
or by Mariusz Chw
Published on 2012-11-27T10:53:10Z
Indexed on
2012/11/27
11:04 UTC
Read the original article
Hit count: 237
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.
© Stack Overflow or respective owner