#include <iostream>
#include <utility>
#include <string>
#include <map>
using namespace std;
int main(){
multimap<string, string> mp;
mp.insert( make_pair("wuhan", "re_gan_mian") );
mp.insert( make_pair("wuhan", "wu_chan_yu") );
/*Output*/
string str = "wuhan";
multimap<string, string>::iterator beiter = mp.lower_bound( str );
multimap<string, string>::iterator eniter = mp.upper_bound( str );
while(beiter != eniter){
cout<< beiter++->second <<endl;
}
multimap<string, string>::iterator it = mp.find("wuhan");
cout<< it->first <<endl;
cout<< it->second <<endl;
return 0;
}
参考文档:http://www.cplusplus.com/reference/map/multimap/?kw=multimap