void SetAt( ARG_KEY key, ARG_VALUE newValue );
Parameters
ARG_KEY
Template parameter specifying the type of the key parameter.
key
Specifies the key of the new element.
ARG_VALUE
Template parameter specifying the type of the newValue parameter.
newValue
Specifies the value of the new element.
Remarks
The primary means to insert an element in a map. First, the key is looked up. If the key is found, then the corresponding value is changed; otherwise a new key-value pair is created.
Example
CMap<int,int,CPoint,CPoint> myMap;
// Add 10 elements to the map.
for (int i=0;i < 10;i++)
myMap.SetAt( i, CPoint(i, i) );
// Remove the elements with even key values.
POSITION pos = myMap.GetStartPosition();
int nKey;
CPoint pt;
while (pos != NULL)
{
myMap.GetNextAssoc( pos, nKey, pt );
if ((nKey%2) == 0)
myMap.RemoveKey( nKey );
}
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "myMap: " << &myMap << "\n";
#endif
CMap Overview | Class Members | Hierarchy Chart
See Also CMap::Lookup, CMap::operator []