16,472
社区成员
发帖
与我相关
我的任务
分享
CMap<int,int,CPoint,CPoint> myMap;
int i;
myMap.InitHashTable( 257 );
// Add 10 elements to the map.
for (i=0;i < 200;i++)
myMap[i] = CPoint(i, i);
// Remove the elements with even key values.
CPoint pt;
for (i=0; myMap.Lookup( i, pt ) ;i+=2)
{
myMap.RemoveKey( i );
}
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