zoukankan      html  css  js  c++  java
  • std::map

    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(" ");
    }

    输出结果:

    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++));     // win32,linux均可用
     linux操作系统下使用itr = map.erase(itr)编译不过去,erase返回值为空。
      

     std::vector<int> vecTestList;

     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不可用

     linux操作系统下使用vector.erase(it++);循环删除列表的过程中第一次循环删除没有问题,第二次循环删除会异常。

    3.map<,<> >在linux下需要有一个空格

  • 相关阅读:
    [HAOI 2007]上升序列
    转载:分布式与集群的区别究竟是什么?
    转载:5个顶级异步Python框架 https://geekflare.com/?s=python
    代码走读 airflow
    走读中学到的技巧 airflow
    sqlalchemy 相关
    pandas 筛选
    pandas IO
    服务端高并发分布式架构演进之路 转载,原文地址:https://segmentfault.com/a/1190000018626163
    pandas 6 时间
  • 原文地址:https://www.cnblogs.com/justkong/p/4782750.html
Copyright © 2011-2022 走看看