// 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一对多用法的更多相关文章

  1. STL——map/unordered_map基础用法

    map /multimap map是STL里重要容器之一. 它的特性总结来讲就是:所有元素都会根据元素的键值key自动排序(也可根据自定义的仿函数进行自定义排序),其中的每个元素都是<key,  ...

  2. STL map 用法

    首先make_pair Pairs C++标准程序库中凡是"必须返回两个值"的函数, 也都会利用pair对象  class pair可以将两个值视为一个单元.容器类别map和mul ...

  3. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  4. STL map详细用法和make_pair函数

    今天练习华为上机测试题,遇到了map的用法,看来博客http://blog.csdn.net/sprintfwater/article/details/8765034:感觉很详细,博主的其他内容也值得 ...

  5. map的详细用法

     map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时 ...

  6. map的详细用法 (转

    map的详细用法: map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能 力,由于这个特性,它完成有可能在我 ...

  7. 详解C++ STL map 容器

    详解C++ STL map 容器 本篇随笔简单讲解一下\(C++STL\)中的\(map\)容器的使用方法和使用技巧. map容器的概念 \(map\)的英语释义是"地图",但\( ...

  8. Features Track[STL map]

    目录 题目地址 题干 代码和解释 参考 题目地址 Features Track(ACM-ICPC 2018 徐州赛区网络预赛 ) 题干 代码和解释 题意:一个动画有许多 n 帧,每帧有 k 个点,点的 ...

  9. map的常见用法

    map的常见用法 map 是什么? map是一组键值对的组合,通俗理解类似一种特殊的数组,a[key]=val,只不过数组元素的下标是任意一种类型,而且数组的元素的值也是任意一种类型.有点类似pyth ...

随机推荐

  1. oracle实例内存(SGA和PGA)调整-xin

    一.名词解释 (1)SGA:System Global Area是Oracle Instance的基本组成部分,在实例启动时分配;系统全局域SGA主要由三部分构成:共享池.数据缓冲区.日志缓冲区. ( ...

  2. MySQL Cluster --01

    [MySQL Cluster] MySQL Cluster 是MySQL 官方集群部署方案, 支持自动分片.读写扩展:通过实时备份冗余数据.适合于分布式计算环境的高实用.高冗余版本,是可用性最高的方案 ...

  3. kibana安装

    kibana,ELK中的K,主要为ES提供界面化操作,据说还是比较炫的,今天安装5.5.2版本进行尝试一把. 安装过程不难,简单的配置了一下端口和IP即可,难度不大. config下的kibana.y ...

  4. 使用CGLib完成代理模式遇到的错误

    错误堆栈信息: Exception in thread "main" java.lang.NoClassDefFoundError: org/objectweb/asm/Type ...

  5. Windows下安装tomcat

    一.Tomcat下载与安装: 1.直接到官网下载Tomcat安装程序包:http://tomcat.apache.org/ 2.下载下来后是个压缩包,如:apache-tomcat-8.0.26,解压 ...

  6. LINUX系统下的数据库的管理

    环境:配置好IP和YUM源  一.数据库的安装及密码的修改 [1]yum  install  mariadb-server  -y       ##安装mariadb数据库 [2]systemctl  ...

  7. LINUX中的DNS服务---高速缓存DNS

    一.什么是DNS     Domain Name System,域名系统.     万维网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网.他主要负责把域名和IP的相互转换 ...

  8. web.xml文件模板

     Servlet 2.3 deployment descriptor 注:web.xml中提示错误The content of element type "web-app" mus ...

  9. Linux下保存文件

    经常需要dump数据,mark一下 #if 0 FILE * fd = NULL; fd = fopen("/mnt/raw.pcm", "ab+"); if ...

  10. tomcat的localhost-config is missing 错误的解决方法

    运行项目时报错,错误信息为: The tomcat server configuration at /sever/tomcat v7.0 localhost-config is missing 解决方 ...