CMap::PLookup

Finds the value mapped to a given key.

const CPair* PLookup(
   ARG_KEY key
) const;
CPair* PLookup( 
   ARG_KEY key 
);

Parameters

  • key
    Key for the element to be searched for.

Return Value

A pointer to a key structure; see CMap::CPair. If no match is found, CMap::PLookup returns NULL.

Remarks

Call this method to search for a map element with a key that exactly matches the given key.

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[i] = CPoint(i, i);

// Print the element values with even key values.
CMyMap::CPair *pCurVal;

for (int i = 0; i <= myMap.GetCount() ; i += 2)
{
   pCurVal = myMap.PLookup(i);
   _tprintf_s(_T("Current key value at %d: %d,%d\n"), 
      pCurVal->key, pCurVal->value.x, pCurVal->value.y);
}      

Requirements

Header: afxtempl.h

See Also

Reference

CMap Class

Hierarchy Chart

CMap::PGetNextAssoc

CMap::PGetFirstAssoc

Other Resources

CMap Members