1.例:

map<int,string> m_mapTest;
m_mapTest.insert(make_pair(1,"kong"));
m_mapTest.insert(make_pair(2,"yang"));
m_mapTest.insert(make_pair(1,"hello1"));
m_mapTest.insert(make_pair(3,"hello3"));
m_mapTest.insert(make_pair(2,"hello2"));

map<int,string>::iterator it = m_mapTest.begin();
for(;it!=m_mapTest.end();it++)
{
string sTem = (*it).second;
::OutputDebugString(sTem.c_str());
::OutputDebugString("\n");
}

输出结果:

kong
yang
hello3

2.vector和map中的erase方法在linux平台和windows平台下的差异

 std::map<int,float>::iterator itr;

 for(itr = i_f_map.begin(); itr != i_f_map.end(); itr = i_f_map.erase(itr));  // win32可用,linux 不可用

 for(itr = i_f_map.begin(); itr != i_f_map.end(); i_f_map.erase(itr++));     // linux,win32可用
  
 std::vector<int> vecTestList;
 vecTestList.push_back(1);
 for(std::vector<int>::iterator it = vecTestList.begin(); it != vecTestList.end(); it = vecTestList.erase(it));  //win32可用,linux不可用
 for(std::vector<int>::iterator it = vecTestList.begin(); it != vecTestList.end(); vecTestList.erase(it++));  //win32不可用,linux可用 

std::map的更多相关文章

  1. C++ std::map

    std::map template < class Key, // map::key_type class T, // map::mapped_type class Compare = less ...

  2. std::map用法

    STL是标准C++系统的一组模板类,使用STL模板类最大的好处就是在各种C++编译器上都通用.    在STL模板类中,用于线性数据存储管理的类主要有vector, list, map 等等.本文主要 ...

  3. C++ std::map::erase用法及其陷阱

    1.引入: STL的map中有一个erase方法用来从一个map中删除制定的节点 eg: map<string,string> mapTest; typedef map<string ...

  4. std::map的clear()没有用?

    昨天晚上,我徒弟跑过来讲,他的程序的内存占用居高不下,愿意是std::map的clear()没有效果.于是我让他用erase(begin,end); 试试也不行. 代码如下: void release ...

  5. std::map的操作:插入、修改、删除和遍历

    using namespace std; std::map<int,int> m_map; 1.添加 for(int i=0;i<10;i++) { m_map.insert(mak ...

  6. Using std::map with a custom class key

    From: https://www.walletfox.com/course/mapwithcustomclasskey.php If you have ever tried to use a cus ...

  7. Std::map too few template arguments

    在上述的代码中,红色波浪线的部分编译的时候报错: error C2976: 'std::map' : too few template arguments 换成std::map<std::str ...

  8. 使用std::map和std::list存放数据,消耗内存比实际数据大得多

    使用std::map和std::list存放数据,消耗内存比实际数据大得多 场景:项目中需要存储一个结构,如下程序段中TEST_DATA_STRU,结构占24B.但是使用代码中的std::list&l ...

  9. STL之std::set、std::map的lower_bound和upper_bound函数使用说明

    由于在使用std::map时感觉lower_bound和upper_bound函数了解不多,这里整理并记录下相关用法及功能. STL的map.multimap.set.multiset都有三个比较特殊 ...

随机推荐

  1. 用java实现zip压缩

    本来是写到spaces live上的,可是代码的显示效果确实不怎么好看.在javaeye上试了试代码显示的顺眼多了. 今天写了个用java压缩的功能,可以实现对文件和目录的压缩. 由于java.uti ...

  2. thinkphp-许愿墙-2

    在数组中,也可以使用函数,如: $data = array( 'username'=> I('username','', 'htmlspecailchars'), 'content'=> ...

  3. MySQL数据库INSERT、UPDATE、DELETE以及REPLACE语句的用法详解

    本篇文章是对MySQL数据库INSERT.UPDATE.DELETE以及REPLACE语句的用法进行了详细的分析介绍,需要的朋友参考下   MySQL数据库insert和update语句引:用于操作数 ...

  4. Git命令家底儿及Git数据通信原理详解

    http://geek.csdn.net/news/detail/72807?utm_source=tuicool&utm_medium=referral

  5. SQL Server 2012不支持从SQL Server 2000的备份进行还原

    错误: dbbackup failed: Unable to restore database 'ppt'Not valid backupThe database was backed up on a ...

  6. Ubuntu 14 Chrome字体设置备份

    Ubuntu 14 Chrome字体设置备份 1.设置 -> 显示高级设置 -> 自定义字体 -> (1) 标准字体:YaHei Consolas Hybrid,14 (2) Ser ...

  7. jQuery Ajax无刷新操作一般处理程序 ashx

    //前台实例代码 aspx文件 <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="ser ...

  8. MongoDB—— 读操作 Core MongoDB Operations (CRUD)

    本文主要介绍内容:从MongoDB中请求数据的不同的方法 Note:All of the examples in this document use the mongo shell interface ...

  9. httpd服务访问控制

    客户机地址限制 通过配置Order.Deny from.Allow from 来限制客户机 allow.deny :先"允许"后"拒绝" ,默认拒绝所有为明确的 ...

  10. 0821找不到Command Line Utility的解决方案

    在Object-C基础教程中写到,要求选择Xcode中Mac OS X - Command Line Utility - Foundation Tool 但在Xcode4.5中Mac OS X中没有C ...