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 ofstd::map<x,y>
,std::map<y,x>
.
using pretty straightforward, although of course need consider question of whether duplicate values allowed.
Comments
Post a Comment