Quantcast
Channel: How to find if a given key exists in a std::map - Stack Overflow
Viewing all articles
Browse latest Browse all 16

Answer by EmreS for How to find if a given key exists in a std::map

$
0
0

If you want to compare pair of map you can use this method:

typedef map<double, double> TestMap;TestMap testMap;pair<map<double,double>::iterator,bool> controlMapValues;controlMapValues= testMap.insert(std::pair<double,double>(x,y));if (controlMapValues.second == false ){    TestMap::iterator it;    it = testMap.find(x);    if (it->second == y)    {        cout<<"Given value is already exist in Map"<<endl;    }}

This is a useful technique.


Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>