#include<hash_map>和#include
int main(){
hash_multimap<int,int> hm;
hm.insert(pair<int,int>(1,10));
hm.insert(pair<int,int>(2,20));
hm.insert(pair<int,int>(2,21));
hm.insert(pair<int,int>(3,30));
hm.insert(pair<int,int>(4,40));
hm.insert(pair<int,int>(2,22));
hm.insert(pair<int,int>(5,50));
hash_multimap<int,int>::iterator beg = hm.begin(), end = hm.end(),ite;
for(ite = beg; ite != end; ite++)
cout << "<" << ite->first << "," << ite->second << ">" << " ";
cout << endl;
hash_multimap<int,int>::iterator beginner, ender, mapIter;
beginner = hm.lower_bound (2);
ender = hm.upper_bound(2);
for(mapIter = beginner; mapIter != ender; mapIter++) {
cout << "<" <<mapIter->first << "," << mapIter->second << ">" << " ";
}
system("pause");
return 0;
}
运行结果