// stlMap.cpp : Defines the entry point for the console application.
//
#pragma warning (disable : 4786 )
#include "stdafx.h"
#include <map>;
#include <string>
#include <iostream>
#include <stdlib.h>
#include <list>;
using namespace std;
int main(int argc, char* argv[])
{
typedef std::list<std::string> StringList;
map<string,StringList>map_roster;
map<string,StringList>::iterator iter;
StringList slMing;
slMing.push_back("mingfei1ÌõÏûÏ¢");
slMing.push_back("mingfei2ÌõÏûÏ¢");
map_roster["mingfei"]=slMing;
slMing.erase(slMing.begin(),slMing.end());
slMing.push_back("1ÌõÏûÏ¢");
slMing.push_back("2ÌõÏûÏ¢");
slMing.push_back("3ÌõÏûÏ¢");
map_roster["ydp"]=slMing;
iter=map_roster.find("mingfei");
// for (;iter!=map_roster.end(); iter++)
// {
cout<<iter->first<<endl;
StringList::const_iterator g = (*iter).second.begin();
for (;g!=(*iter).second.end();g++)
{
cout<<(*g).c_str()<<endl;
}
//}
/*
StringList::const_iterator it2=(*iter).second.begin();
for (;it2<(*iter).second.end();it2++)
{
//cout<<(*it2).c_str()<<endl;
cout<<"333"<<endl;
}
*/
system("pause");
return 0;
}
stl map一对多用法
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:CFile用法(转)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
STL map 用法
STL map find
STL 用法 map -
STL MAP用法详解
(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们
string iterator iostream insert pair -
STL--- map的用法
最全的c++map的用法Map是STL[1] 的一个关联容器,它提供一对一
STL--- map的用法 C++ 迭代器 #include 数据 -
STL map用法总结(multimap)
2017-08-19 10:58:52 writer;pprp 另外multimap用法与map类似,函数什么的都一样,只是支持一个key对多个value
map STL multimap #include 数据 -
Map扩展一对多的使用
map集合的扩展一对多关系
java Map List System