CMap::SetAt

주 지도에 요소를 삽입 하 고

void SetAt(
   ARG_KEY key,
   ARG_VALUE newValue 
);

매개 변수

  • ARG_KEY
    템플릿 매개 변수 형식을 지정 하는 key 매개 변수.

  • key
    새 요소의 키를 지정합니다.

  • ARG_VALUE
    템플릿 매개 변수 형식을 지정 하는 newValue 매개 변수.

  • newValue
    새 요소의 값을 지정합니다.

설명

먼저 키를 찾습니다.해당 값을 변경 하 고 키를 찾을 경우. 그렇지 않으면 새 키-값 쌍을 만듭니다.

예제

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

// Print the element values.
pos = myMap.GetStartPosition();
while (pos != NULL)
{
   myMap.GetNextAssoc(pos, nKey, pt);
   _tprintf_s(_T("Current key value at %d: %d,%d\n"), 
      nKey, pt.x, pt.y);
}      

요구 사항

헤더: afxtempl.h

참고 항목

참조

클래스 CMap

계층 구조 차트

CMap::Lookup

CMap::operator]