C++ STL map

简介

遍历

// 正向遍历
map<int, int>::iterator i = mymap.begin();
while(i != mymap.end()){
    cout << i->first << " " << i->second;
    i++
}

// 反向遍历
map<int, int>::reverse_iterator i = mymap.rbegin();
while(i != mymap.rend()){
    cout << i->first << " " << i->second;
    i++
}
posted @ 2020-02-15 23:04  阳离子  阅读(129)  评论(0)    收藏  举报