CMap::PLookup

找到该值映射到特定键。

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

参数

  • key
    元素的键可以将搜索。

返回值

对密钥的结构的指针; CMap::CPair参见。 如果没有找到匹配项,CMap::PLookup 返回 NULL。

备注

调用此方法将搜索完全匹配特定键的键映射元素。

示例

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);
}      

要求

Header: afxtempl.h

请参见

参考

CMap选件类

层次结构图

CMap::PGetNextAssoc

CMap::PGetFirstAssoc