c++ - How can I find out if a map contains a given value? -


i'd find out whether given value present in map. getting corresponding key(s) nice not required.

bool map::contains(string value); 

is there simple way other iterate on whole map , comparing each value given value? why there no corresponding method in stl?

std::map indexes elements key; not index them value. therefore, there no way element value without iterating on map.

take @ boost.bimap:

boost.bimap bidirectional maps library c++. boost.bimap can create associative containers in both types can used key. bimap<x,y> can thought of combination of std::map<x,y> , std::map<y,x>.

using pretty straightforward, although of course need consider question of whether duplicate values allowed.

also, see is there boost.bimap alternative in c++11?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -