1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
// multimap::lower_bound/upper_bound
#include <iostream>
#include <map>
using namespace std;
int main ()
{
multimap<char,int> mymultimap;
multimap<char,int>::iterator it,itlow,itup;
mymultimap.insert(pair<char,int>('a',10));
mymultimap.insert(pair<char,int>('b',121));
mymultimap.insert(pair<char,int>('c',1001));
mymultimap.insert(pair<char,int>('c',2002));
mymultimap.insert(pair<char,int>('d',11011));
mymultimap.insert(pair<char,int>('e',44));
itlow=mymultimap.lower_bound ('b'); // itlow points to b
itup=mymultimap.upper_bound ('d'); // itup points to e (not d)
// print range [itlow,itup):
for ( it=itlow ; it != itup; it++ )
cout << (*it).first << " => " << (*it).second << endl;
return 0;
}
|