#include <iostream>
#include <map>
#include <string>
using namespace std
;
int main()
{
typedef std
::map
<string
, int> StringIntMap
;
StringIntMap coll
;
coll
["aa"] = 1;
coll
["bb"] = 2;
coll
["cc"] = 1;
coll
["dd"] = 2;
int value
= 1;
for (StringIntMap
::iterator pos
= coll
.begin(); pos
!= coll
.end(); )
{
if (pos
->second
== 1)
{
pos
= coll
.erase(pos
);
}
else
{
++pos
;
}
}
for (StringIntMap
::iterator pos
= coll
.begin(); pos
!= coll
.end(); ++pos
)
{
std
::cout
<< "key:" << pos
->first
<< " value:" << pos
->second
<< std
::endl
;
}
getchar();
return 0;
}
转载请注明原文地址: https://lol.8miu.com/read-25086.html