map::equal_range

// map::equal_elements
#include 
#include 
using namespace std;

int main ()
{
  map mymap;
  pair::iterator,map::iterator> ret;

  mymap['a']=10;
  mymap['b']=20;
  mymap['c']=30;

  ret = mymap.equal_range('b');

  cout << "lower bound points to: ";
  cout << ret.first->first << " => " << ret.first->second << endl;

  cout << "upper bound points to: ";
  cout << ret.second->first << " => " << ret.second->second << endl;

  return 0;
}


lower bound points to: 'b' => 20
upper bound points to: 'c' => 30

你可能感兴趣的:(c++,STL)