| <<< map iterators | Index | map::insert >>> |
Use find( key ) to get an iterator for a specific key:
typedef map<string, int> MapT;
typedef MapT::const_iterator MapIterT;
MapT amap;
MapIterT result = amap.find( "Fred" );
if ( result != amap.end() ) {
// Print out map in alpha. order, starting with Fred
for( MapIterT mit = result; mit != amap.end(); mit++ ) {
cout
<< mit->first
<< " "
<< mit->second
<< endl
;
}
}
| <<< map iterators | Index | map::insert >>> |