读书人

map最好不用在使用的时候删除东西

发布时间: 2012-06-22 16:16:32 作者: rapoo

map最好不要在使用的时候删除东西

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;
}

读书人网 >软件开发

热点推荐