#include <iostream>
#include <map>
#include <string> using namespace std; int main()
{
multimap<string, string> authors; // 插入元素, 引入的头文件是 map
authors.insert(make_pair(
string("Evin"), // 这个是 Key
string("Hi"))); authors.insert(make_pair(
string("Evin"), // 跟上面的一样,是同一个key
string("Hello"))); typedef multimap<string, string>::const_iterator mmap_cit; // 第一种遍历方式
mmap_cit beg = authors.lower_bound("Evin");
mmap_cit end = authors.upper_bound("Evin"); while(beg != end)
{
cout<<beg->second<<endl;
++beg;
} // 另外一种遍历方式
pair<mmap_cit, mmap_cit> pos = authors.equal_range("Evin"); while(pos.first != pos.second)
{
cout<<pos.first->second<<endl;
++pos.first;
} cout<<authors.erase("Evin")<<endl; // erase 返回删除的元素个数 return 0;
}

利用 multimap 能够做到一个key, 同一时候相应多个value

最新文章

  1. css3 rem的用法
  2. yum -y upgrade 和 yum -y update 区别
  3. Innodb行锁源码学习(一)
  4. PDP 有多种定义,具体哪一种还需研究!!!!
  5. susy-Toolkit 之翻译
  6. c语言中static 用法总结(转)
  7. Python中的List,Tuple,Dic,Set
  8. Mac OS X下Maven的安装与配置
  9. PHP 字符串处理 总结
  10. springMVC项目异步处理请求的错误Async support must be enabled on a servlet and for all filters involved in async
  11. php中curl远程调用获取数据
  12. MySQL 报错 _DATA_TYPE_INVALID_
  13. 学习EtherCAT的感想
  14. JS 最简单数组去重
  15. 一些简单的ajax的特点,方法、属性。以及ajax的创建 请求
  16. AngularJS学习之旅—AngularJS 表达式(二)
  17. java数据库导入excel数据
  18. Odoo 8 Graph 视图 之 雷达图 (Radar\Spider)
  19. sql server 清除数据库中所有表的数据
  20. P&lt;0.05就够了?还要校正!校正!3个方法献上

热门文章

  1. [Angular 2] *ngFor with index
  2. windows下php+apache+mysql环境搭建
  3. Linux驱动设备中的并发控制
  4. 函数返回char* 的解决方案
  5. Hibernate Validation各注解的用法
  6. jquery之onchange事件2
  7. 黑马程序员——HTML语言
  8. HTML5框架、背景和实体、XHTML的使用规范
  9. (转)使用Microsoft Web Application Stress Tool对web进行压力测试
  10. 3.Android Studio系列教程3——快捷键