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 ...
随机推荐
- OLT配置说明
MA5680T>enable 进入特权模式 MA5680T#config 进入配置模式 MA5680T(config)#display current-configuration sim ...
- web前端看IE11的变化
一.User-agent的变化 IE11的User-agent Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko IE10的U ...
- centos7 iptables替换firewall
Disable Firewalld Service. [root@rhel-centos7-tejas-barot-linux ~]# systemctl mask firewalld Stop Fi ...
- mysql的搭建
创建程序用户 root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -s /sbin/nologin -g mysql -M my ...
- Yii ExtendedActiveRecord 增强版 ActiveRecord 增加多数据库连接绑定功能
ExtendedActiveRecord 继承自 CActiveRecord,因此基础功能与 CActiveRecord 无异 为添加对多数据库连接的支持,增加了对 connectionName() ...
- python之阶乘的小例子
现在自己写阶乘是这个样子的 def f(x): return x * f(x-1) if x >1 else 1 后来无意中看到耗子的一篇<Python程序员的进化>的文章, 感脚这 ...
- shell脚本实例二
练习题一:对已经存在的用户做密码的修改等操作 vim user_ctrl.sh ##进行如下编写 #!/bin/bashShow(){ read -p ...
- React-Native基础_5.列表视图ListView 网络数据展示
//获取网络数据 并用列表展示 豆瓣Top250 api /** * Sample React Native App * https://github.com/facebook/react-nativ ...
- Unity内存优化技术测试案例
笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家,特邀编辑,畅销书作者,已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D实战核心技术详解 ...
- 369C Valera and Elections
http://codeforces.com/problemset/problem/369/C 树的遍历,dfs搜一下,从根节点搜到每个分叉末尾,记录一下路况,如果有需要修复的,就把分叉末尾的节点加入答 ...