#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;
}
本文来自优快云博客,转载请标明出处:http:
//blog.youkuaiyun.com/xtayaitak/archive/2010/10/27/5968090.aspx
|
多重映射
最新推荐文章于 2024-05-24 13:58:17 发布