• 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下需要有一个空格

  • 相关阅读:
    flex布局
    媒体查询
    transform详细解释
    读取long类型数据
    Oracle中快速清空当前用户的所有表数据
    没有表头的csv文件怎么导入Kettle
    Kettle性能调优汇总
    oralce中特殊字符的查询
    数据的单值、多值、派生、简单、复合属性
    kettle学习
  • 原文地址:https://www.cnblogs.com/justkong/p/4782750.html
Copyright © 2020-2023  润新知