Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ multimap equal_range found nothing

Tags:

c++

multimap

How can I know the equal_range didn't find any match cases?

like:

multimap<string,string> mapdic;
pair<multimap<string,string>::iterator,multimap<string,string>::iterator> ret;
// insert some string pairs


ret=mapdic.equal_range(thisUpperCaseName);


    if (???)//how to test equal_range find nothing?
    {       
}else{

     }

Anyone can help?

Thanks

like image 429
Steven Du Avatar asked Aug 25 '11 04:08

Steven Du


1 Answers

:)

say your equal_range returns result of type pair

If your result.first == result.second then it means there is nothing.

If there is even a single element then result.first != result.second

if(ret.first == ret.second)
{
 // empty range
}
else
{
  //at least an element.
}
like image 86
Ajeet Ganga Avatar answered Nov 08 '22 02:11

Ajeet Ganga