im wondering if you can use the STL binary_search on STL map. I've tried but still cant get it to work
map<int,string> dataMap;
if(binary_search (dataMap.begin().first, dataMap.end().first, key))
// do some stuff
Thanks in advance! :)
STL map
is inherently a binary search tree - just use map::find
. Using container member functions, where they are present, is preferable to algorithms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With