map最好不要在使用的时候删除东西
2012-06-21 16:42
381 查看
typedef map<int, int> templatemap;
templatemap AllScoreSort;
for(int i=10000;i<10010;i++)
AllScoreSort[i]=i+1;
for (templatemap::iterator iter = AllScoreSort.begin(); iter!= AllScoreSort.end(); iter++)
{
int nRoleID = iter->first;
int nScore = iter->second;
if (10005 < nRoleID)
{
//AllScoreSort.erase(nRoleID); //注意这行
continue;
}
cout<<nRoleID<<" "<<nScore<<endl;
}
templatemap AllScoreSort;
for(int i=10000;i<10010;i++)
AllScoreSort[i]=i+1;
for (templatemap::iterator iter = AllScoreSort.begin(); iter!= AllScoreSort.end(); iter++)
{
int nRoleID = iter->first;
int nScore = iter->second;
if (10005 < nRoleID)
{
//AllScoreSort.erase(nRoleID); //注意这行
continue;
}
cout<<nRoleID<<" "<<nScore<<endl;
}
相关文章推荐
- 2008-03-23 | 有些东西最好不要看
- C++文本查询程序 不要定义类和智能指针管理数据 C++Primer练习12.28 使用vector,map,set容器保存来自文件的数据并生成查询结果
- hibernate 字段名最好不要使用数据库的保留字
- 如何查看/删除使用WANem或者其它时候的网关设置
- HiveServer2 的jdbc方式创建udf的修改(add jar 最好不要使用),否则会造成异常: java.sql.SQLException: Error while processing statement: null
- 集合已修改;枚举操作可能无法执行。使用foreach 循环删除DataRow的时候的问题! 该死的AcceptChanges() Row.elete() Remove(Row)使用不同。
- 使用array_map简单搞定PHP删除文件、删除目录
- JavaScript中遍历数组 最好不要使用 for in 遍历
- 这段时间一直在做iconfont.cn这个平台。积累了些东西,记录下。 1.什么是iconfont? iconfont不是什么新技术了。 我们知道web网页能使用的字体一直很少,很多时候设计师用ps
- 用CheckBox做删除时请不要使用@Html.CheckBoxFor
- Scripts:从shared_pool中创建并删除profile的脚本(注意,此脚本危险比较高,生产环境不要使用)flush_sql10p.sql
- C++ STL遍历map的时候如何删除其中的element
- C++文本查询程序 不要定义类和智能指针管理数据 C++Primer练习12.28 使用vector,map,set容器保存来自文件的数据并生成查询结果
- unity打包IOS最好不要使用的排序方法
- 当你使用GridView的时候,不要在page_load中绑定数据
- 是使用Net Configuration Assistant,配置监听,或者删除监听的时候,一定要点击”完成“。否则,无效
- 在使用git的时候,删除了本地仓库的许多文件的时候引起错误。
- 当你使用LINQ做底层时,最好设计一个工厂,不要把LINQ的动作暴露给业务层
- 写GStreamer插件的时候,不要使用全局变量!