2011年3月2日
摘要: 如果erase()总是返回下一元素的位置,那就可以像在vector容器中删除元素一样,如:// 删除所有实值为2的元素 map< int, int >::iterator itMap = mapInt.begin(); for ( ; itMap != mapInt.end(); ) { if ( itMap->second == 2 ) { itMap = mapInt.erase( itMap ); } else { ++itMap; } }但是,注意,以上的方式只在vc使用P.J.STL中才能编译通过,而使用SGI STL库则编译不过,因为SGISTL库在设计中考虑到如 阅读全文
posted @ 2011-03-02 11:10 Ray_8686 阅读(1754) 评论(0) 推荐(0) 编辑