stl map一对多用法
// 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一对多用法的更多相关文章
- STL——map/unordered_map基础用法
map /multimap map是STL里重要容器之一. 它的特性总结来讲就是:所有元素都会根据元素的键值key自动排序(也可根据自定义的仿函数进行自定义排序),其中的每个元素都是<key, ...
- STL map 用法
首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象 class pair可以将两个值视为一个单元.容器类别map和mul ...
- POJ 3096 Surprising Strings(STL map string set vector)
题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...
- STL map详细用法和make_pair函数
今天练习华为上机测试题,遇到了map的用法,看来博客http://blog.csdn.net/sprintfwater/article/details/8765034:感觉很详细,博主的其他内容也值得 ...
- map的详细用法
map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...
- map的详细用法 (转
map的详细用法: map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能 力,由于这个特性,它完成有可能在我 ...
- 详解C++ STL map 容器
详解C++ STL map 容器 本篇随笔简单讲解一下\(C++STL\)中的\(map\)容器的使用方法和使用技巧. map容器的概念 \(map\)的英语释义是"地图",但\( ...
- Features Track[STL map]
目录 题目地址 题干 代码和解释 参考 题目地址 Features Track(ACM-ICPC 2018 徐州赛区网络预赛 ) 题干 代码和解释 题意:一个动画有许多 n 帧,每帧有 k 个点,点的 ...
- map的常见用法
map的常见用法 map 是什么? map是一组键值对的组合,通俗理解类似一种特殊的数组,a[key]=val,只不过数组元素的下标是任意一种类型,而且数组的元素的值也是任意一种类型.有点类似pyth ...
随机推荐
- Slasher Flick
打不死的小强! 返回一个数组被截断n个元素后还剩余的元素,截断从索引0开始. 这是一些对你有帮助的资源: Array.slice() Array.splice() 按照提供的第一种方法,代码如下: f ...
- log4cpp
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- echarts-detail--柱状图
一:柱形图 1.Echarts-柱状图柱图宽度设置-----只需要设置series中的坐标系属性barWidth就可以 /** * 堆积柱状图 * @param xaxisdata x轴:标签(数组) ...
- 特殊的 html 空格
http://www.zhangxinxu.com/wordpress/2015/01/tips-blank-character-chinese-align/
- 高并发异步uwsgi+web.py+gevent
为什么用web.py? python的web框架有很多,比如webpy.flask.bottle等,但是为什么我们选了webpy呢?想了好久,未果,硬要给解释,我想可能原因有两个:第一个是兄弟项目组用 ...
- Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
- 动态Json字符串的解析
动态Json字符串的解析 对于传统的Json字符串,比如有规定属性的对象,通常都会采用反序列化的方式就可以了,例如下面的方式: DataContractJsonSerializer ser = new ...
- Eclipse远程调试Java程序
1. 在服务器上运行jar包时加入参数 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address= 2. 在Eclipse中操作 ...
- 机器学习中的ground truth
ground truth就是参考标准,一般用来做误差量化.比方说要根据历史数据预测某一时间的温度,ground truth就是那个时间的真实温度.error就是(predicted temperatu ...
- 压力测试工具ab及centos下单独安装方法
压力测试工具Ab简介 Apache安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了. 1.独立安装 ab运行需要依赖apr-uti ...