Use insert( ) to put in a new item only if it isn't there:
#include <cassert>
#include <string>
#include <map>
using namespace std;
typedef map<string, int> MapT;
typedef MapT::const_iterator MapIterT;
int main()
{
MapT amap;
pair< MapIterT, bool> result =
amap.insert( make_pair( "Fred", 45 ) );
assert( result.second == true );
assert( result.first->second == 45 );
result = amap.insert( make_pair( "Fred", 54 ) );
// Fred was already in the map, and result.first
// simply points there now:
assert( result.second == false );
assert( result.first->second == 45 );
}