共用方式為


CMap::PGetFirstAssoc

Returns the first entry of the map object.

const CPair* PGetFirstAssoc( ) const; 
CPair* PGetFirstAssoc( );

Return Value

A pointer to the first entry in the map; see CMap::CPair. If the map contains no entries, the value is NULL.

Remarks

Call this function to return a pointer the first element in the map object.

Example

typedef CMap<int, int, CPoint, CPoint> CMyMap;
CMyMap myMap;

myMap.InitHashTable(257);

// Add 10 elements to the map.
for (int i = 0; i <= 10; i++)
   myMap.SetAt(i, CPoint(i, i));

// Print the element value with even key values.
int nKey = 0;
CPoint pt;
CMyMap::CPair* pCurVal;

pCurVal = myMap.PGetFirstAssoc();
while (pCurVal != NULL)
{
   if ((nKey%2) == 0)
   {
      _tprintf_s(_T("Current key value at %d: %d,%d\n"),
         pCurVal->key, pCurVal->value.x, pCurVal->value.y);
   }
   pCurVal = myMap.PGetNextAssoc(pCurVal);
   nKey++;
}

Requirements

Header: afxtempl.h

See Also

Concepts

CMap Class

CMap Members

Hierarchy Chart

CMap::PGetNextAssoc

CMap::PLookup