多重映射
#include <iostream>
#include <map>
#include <string>
using namespace std;
typedef multimap<string,string>::value_type CIT;
typedef multimap<string,string>::const_iterator IT;
template<class T1,class T2>
void show(IT&it,multimap<T1,T2>&r)
{
for(it=r.begin();it!=r.end();++it)
cout<<it->first<<"\t"<<it->second<<"\n";
}
int main()
{
multimap<string,string>phone;
phone.insert(CIT("朱然","6464684684684"));
phone.insert(CIT("朱然","64646"));
phone.insert(CIT("朱然","64646846"));
IT ii;
cout<<"遍历whole ele"<<endl;
show(ii,phone);
cout<<"find data of the keyword is 朱然"<<endl;
ii=phone.find("朱然");
typedef pair<IT,IT> PAIR;
PAIR p=phone.equal_range("朱然");
for(IT i=p.first;i!=p.second;++i)
{
cout<<i->first<<"\t"<<i->second<<endl;
}
system("pause");
return 0;
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xtayaitak/archive/2010/10/27/5968090.aspx
本文章转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232

浙公网安备 33010602011771号