다음을 통해 공유


CList 클래스

순차적으로 또는 값별로 액세스할 수 있고 고유하지 않은 개체의 순서가 지정된 목록을 지원합니다.

구문

template<class TYPE, class ARG_TYPE = const TYPE&>
class CList : public CObject

멤버

공용 생성자

속성 설명
CList::CList 정렬된 빈 목록을 생성합니다.

공용 메서드

이름 설명
CList::AddHead 목록의 머리글에 요소(또는 다른 목록의 모든 요소)를 추가합니다(새 헤드를 만듭니다).
CList::AddTail 요소(또는 다른 목록의 모든 요소)를 목록의 꼬리에 추가합니다(새 꼬리를 만듭니다).
CList::Find 포인터 값으로 지정된 요소의 위치를 가져옵니다.
CList::FindIndex 0부터 시작하는 인덱스로 지정된 요소의 위치를 가져옵니다.
CList::GetAt 지정된 위치에 있는 요소를 가져옵니다.
CList::GetCount 이 목록의 요소 수를 반환합니다.
CList::GetHead 목록의 헤드 요소를 반환합니다(비워 둘 수 없음).
CList::GetHeadPosition 목록의 헤드 요소 위치를 반환합니다.
CList::GetNext 반복할 다음 요소를 가져옵니다.
CList::GetPrev 반복할 이전 요소를 가져옵니다.
CList::GetSize 이 목록의 요소 수를 반환합니다.
CList::GetTail 목록의 tail 요소를 반환합니다(비워 둘 수 없음).
CList::GetTailPosition 목록의 tail 요소 위치를 반환합니다.
CList::InsertAfter 지정된 위치 뒤에 새 요소를 삽입합니다.
CList::InsertBefore 지정된 위치 앞에 새 요소를 삽입합니다.
CList::IsEmpty 빈 목록 조건(요소 없음)을 테스트합니다.
CList::RemoveAll 이 목록에서 모든 요소를 제거합니다.
CList::RemoveAt 위치로 지정된 이 목록에서 요소를 제거합니다.
CList::RemoveHead 목록의 머리에서 요소를 제거합니다.
CList::RemoveTail 목록의 꼬리에서 요소를 제거합니다.
CList::SetAt 지정된 위치에 요소를 설정합니다.

매개 변수

TYPE
목록에 저장된 개체의 형식입니다.

ARG_TYPE
목록에 저장된 개체를 참조하는 데 사용되는 형식입니다. 참조일 수 있습니다.

설명

CList 목록은 이중으로 연결된 목록처럼 동작합니다.

형식 POSITION 변수는 목록의 키입니다. 변수를 POSITION 반복기로 사용하여 목록을 순차적으로 트래버스하고 책갈피로 배치할 수 있습니다. 그러나 위치는 인덱스와 동일하지 않습니다.

요소 삽입은 목록 머리, 꼬리 및 알려진 POSITION위치에서 매우 빠릅니다. 값 또는 인덱스별로 요소를 조회하려면 순차적 검색이 필요합니다. 목록이 길면 이 검색 속도가 느려질 수 있습니다.

목록에 개별 요소의 덤프가 필요한 경우 덤프 컨텍스트의 깊이를 1 이상으로 설정해야 합니다.

이 클래스의 특정 멤버 함수는 대부분의 클래스 사용에 맞게 사용자 지정해야 하는 전역 도우미 함수를 CList 호출합니다. "매크로 및 전역" 섹션에서 컬렉션 클래스 도우미를 참조하세요.

사용에 CList대한 자세한 내용은 컬렉션 문서를 참조하세요.

예시

// CList is a template class that takes two template arguments.
// The first argument is type stored internally by the list, the
// second argument is the type used in the arguments for the
// CList methods.

// This code defines a list of ints.
CList<int, int> myIntList;

// This code defines a list of CStrings
CList<CString, CString &> myStringList;

// This code defines a list of MYTYPEs,
// NOTE: MYTYPE could be any struct, class or type definition
CList<MYTYPE, MYTYPE &> myTypeList;

상속 계층 구조

CObject

CList

요구 사항

헤더afxtempl.h:

CList::AddHead

새 요소 또는 요소 목록을 이 목록의 머리글에 추가합니다.

POSITION AddHead(ARG_TYPE newElement);
void AddHead(CList* pNewList);

매개 변수

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다(참조일 수 있음).

newElement
새 요소입니다.

pNewList
다른 CList 목록에 대한 포인터입니다. 이 목록에 요소가 pNewList 추가됩니다.

Return Value

첫 번째 버전은 새로 삽입된 요소의 값을 반환 POSITION 합니다.

설명

작업 전에 목록을 비울 수 있습니다.

예시

// Declarations of the variables used in the example
CList<CString, CString &> myList;
CList<CString, CString &> myList2;

// There are two versions of CList::AddHead: one adds a single
// element to the front of the list, the second adds another list
// to the front.

// This adds the string "ABC" to the front of myList.
// myList is a list of CStrings (ie defined as CList<CString,CString&>).
myList.AddHead(CString(_T("ABC")));

// This adds the elements of myList2 to the front of myList.
myList.AddHead(&myList2);

CList::AddTail

새 요소 또는 요소 목록을 이 목록의 뒷부분에 추가합니다.

POSITION AddTail(ARG_TYPE newElement);
void AddTail(CList* pNewList);

매개 변수

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다(참조일 수 있음).

newElement
이 목록에 추가할 요소입니다.

pNewList
다른 CList 목록에 대한 포인터입니다. 이 목록에 요소가 pNewList 추가됩니다.

Return Value

첫 번째 버전은 새로 삽입된 요소의 값을 반환 POSITION 합니다.

설명

작업 전에 목록을 비울 수 있습니다.

예시

// Define myList and myList2.
CList<CString, CString &> myList;
CList<CString, CString &> myList2;

// Add elements to the end of myList and myList2.
myList.AddTail(CString(_T("A")));
myList.AddTail(CString(_T("B")));
myList2.AddTail(CString(_T("C")));
myList2.AddTail(CString(_T("D")));

// There are two versions of CList::AddTail: one adds a single
// element to the end of the list, the second adds another list
// to the end.

// This adds the string "ABC" to the end of myList.
// myList is a list of CStrings (ie defined as CList<CString,CString&>).
myList.AddTail(CString(_T("ABC")));
ASSERT(CString(_T("ABC")) == myList.GetTail());

// This adds the elements of myList2 to the end of myList.
myList.AddTail(&myList2);

CList::CList

정렬된 빈 목록을 생성합니다.

CList(INT_PTR nBlockSize = 10);

매개 변수

nBlockSize
목록을 확장하기 위한 메모리 할당 세분성입니다.

설명

목록이 커짐에 따라 메모리가 항목 단위 nBlockSize 로 할당됩니다.

예시

// This code defines myList as a list of strings
// such that memory gets allocated in chunks of
// 16 strings.
CList<CString, CString &> myList(16);

// This code defines myList2 as a list of ints
// such that memory gets allocated in chunks of
// 128 ints.
CList<int, int> myList2(128);

CList::Find

목록을 순차적으로 검색하여 지정된 요소와 일치하는 첫 번째 요소를 찾습니다 searchValue.

POSITION Find(
    ARG_TYPE searchValue,
    POSITION startAfter = NULL) const;

매개 변수

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다(참조일 수 있음).

searchValue
목록에서 찾을 값입니다.

startAfter
검색의 시작 위치입니다. 값을 지정하지 않으면 검색이 헤드 요소로 시작됩니다.

Return Value

POSITION 개체를 찾을 수 없는 경우 반복 또는 개체 포인터 검색 NULL 에 사용할 수 있는 값입니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
myList.AddHead(CString(_T("XYZ")));
myList.AddHead(CString(_T("ABC")));
myList.AddHead(CString(_T("123")));

// Find a specific element.
POSITION pos = myList.Find(CString(_T("XYZ")));
ASSERT(CString(_T("XYZ")) == myList.GetAt(pos));

CList::FindIndex

목록에 인덱스로 값을 nIndex 사용합니다.

POSITION FindIndex(INT_PTR nIndex) const;

매개 변수

nIndex
찾을 목록 요소의 인덱스(0부터 시작)입니다.

Return Value

POSITION 반복 또는 개체 포인터 검색 NULL 에 사용할 수 있는 값입니다(음수이거나 너무 큰 경우nIndex).

설명

목록의 머리에서 순차적 검색을 시작하여 n번째 요소에서 중지합니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
myList.AddTail(CString(_T("XYZ")));
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Verify the first element (index 0).
ASSERT(CString(_T("XYZ")) == myList.GetAt(myList.FindIndex(0)));

// Verify the third element (index 2).
ASSERT(CString(_T("123")) == myList.GetAt(myList.FindIndex(2)));

CList::GetAt

지정된 위치에 있는 목록 요소를 가져옵니다.

TYPE& GetAt(POSITION position);
const TYPE& GetAt(POSITION position) const;

매개 변수

TYPE
목록에 있는 개체의 형식을 지정하는 템플릿 매개 변수입니다.

position
가져올 요소 목록의 위치입니다.

Return Value

에 대한 GetHead반환 값 설명을 참조하세요.

설명

GetAt 는 지정된 위치와 연결된 요소(또는 요소에 대한 참조)를 반환합니다. 인덱스와 동일하지 않으며 직접 값에 POSITION 대해 작업할 수 없습니다. 형식 POSITION 변수는 목록의 키입니다.

값이 POSITION 목록에서 유효한 위치를 나타내는지 확인해야 합니다. 잘못된 경우 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다.

예시

에 대한 예제를 CList::GetHeadPosition참조하세요.

CList::GetCount

이 목록의 요소 수를 가져옵니다.

INT_PTR GetCount() const;

Return Value

요소 수를 포함하는 정수 값입니다.

설명

이 메서드를 호출하면 메서드와 동일한 결과가 CList::GetSize 생성됩니다.

예시

에 대한 예제를 CList::RemoveHead참조하세요.

CList::GetHead

이 목록의 헤드 요소(또는 헤드 요소에 대한 참조)를 가져옵니다.

const TYPE& GetHead() const;

TYPE& GetHead();

매개 변수

TYPE
목록에 있는 개체의 형식을 지정하는 템플릿 매개 변수입니다.

Return Value

목록이면 constGetHead 목록의 머리글에 있는 요소의 복사본을 반환합니다. 이렇게 하면 함수를 대입 문의 오른쪽에서만 사용할 수 있으며 목록을 수정하지 않도록 보호합니다.

목록이 아닌 constGetHead 경우 목록의 머리글에 있는 요소에 대한 참조를 반환합니다. 이렇게 하면 할당 문의 양쪽에서 함수를 사용할 수 있으므로 목록 항목을 수정할 수 있습니다.

설명

를 호출 GetHead하기 전에 목록이 비어 있지 않은지 확인해야 합니다. 목록이 비어 있으면 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다. 목록에 요소가 포함되어 있는지 확인하는 데 사용합니다 IsEmpty .

예시

// Define myList.
CList<CString, CString &> myList;

// Add an element to the front of the list.
myList.AddHead(CString(_T("ABC")));

// Verify the element was added to the front of the list.
ASSERT(CString(_T("ABC")) == myList.GetHead());

CList::GetHeadPosition

이 목록의 헤드 요소 위치를 가져옵니다.

POSITION GetHeadPosition() const;

Return Value

POSITION 목록이 비어 있는 경우 반복 또는 개체 포인터 검색 NULL 에 사용할 수 있는 값입니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add an element to the front of the list.
myList.AddHead(CString(_T("ABC")));

// Verify the element at the head position
// is the one added.
POSITION pos = myList.GetHeadPosition();
ASSERT(CString(_T("ABC")) == myList.GetAt(pos));

CList::GetNext

식별된 rPosition목록 요소를 가져오고 목록에서 다음 항목의 값으로 설정합니다 rPositionPOSITION .

TYPE& GetNext(POSITION& rPosition);
const TYPE& GetNext(POSITION& rPosition) const;

매개 변수

TYPE
목록에 있는 요소의 형식을 지정하는 템플릿 매개 변수입니다.

rPosition
이전 GetNext또는 GetHeadPosition다른 멤버 함수 호출에서 반환된 값에 대한 참조 POSITION 입니다.

Return Value

목록이면 constGetNext 목록 요소의 복사본을 반환합니다. 이렇게 하면 함수를 대입 문의 오른쪽에서만 사용할 수 있으며 목록을 수정하지 않도록 보호합니다.

목록이 아닌 constGetNext 경우 목록의 요소에 대한 참조를 반환합니다. 이렇게 하면 할당 문의 양쪽에서 함수를 사용할 수 있으므로 목록 항목을 수정할 수 있습니다.

설명

또는 호출을 사용하여 초기 위치를 설정하는 경우 정방향 반복 루프에서 GetHeadPositionFind사용할 GetNext 수 있습니다.

값이 POSITION 목록에서 유효한 위치를 나타내는지 확인해야 합니다. 잘못된 경우 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다.

검색된 요소가 목록의 마지막 요소이면 새 값 rPosition 이 NULL로 설정됩니다.

예시

// Define myList.
// Define myList.
CList<CString, CString &> myList;

// Add two elements to the list.
myList.AddHead(CString(_T("ABC")));
myList.AddHead(CString(_T("123")));

// Dump the list elements to the debug window.
POSITION pos = myList.GetHeadPosition();
for (int i = 0; i < myList.GetCount(); i++)
{
   TRACE(_T("%s\r\n"), (LPCTSTR)myList.GetNext(pos));
}

CList::GetPrev

식별된 rPosition목록 요소를 가져온 다음 목록에서 이전 항목의 값으로 설정합니다 rPositionPOSITION .

TYPE& GetPrev(POSITION& rPosition);
const TYPE& GetPrev(POSITION& rPosition) const;

매개 변수

TYPE
목록에 있는 요소의 형식을 지정하는 템플릿 매개 변수입니다.

rPosition
이전 GetPrev 또는 다른 멤버 함수 호출에서 반환된 값에 대한 참조 POSITION 입니다.

Return Value

목록이면 constGetPrev 목록의 머리글에 있는 요소의 복사본을 반환합니다. 이렇게 하면 함수를 대입 문의 오른쪽에서만 사용할 수 있으며 목록을 수정하지 않도록 보호합니다.

목록이 아닌 constGetPrev 경우 목록의 요소에 대한 참조를 반환합니다. 이렇게 하면 할당 문의 양쪽에서 함수를 사용할 수 있으므로 목록 항목을 수정할 수 있습니다.

설명

호출 GetTailPositionFind사용하여 초기 위치를 설정하는 경우 역방향 반복 루프에서 사용할 GetPrev 수 있습니다.

값이 POSITION 목록에서 유효한 위치를 나타내는지 확인해야 합니다. 잘못된 경우 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다.

검색된 요소가 목록의 첫 번째 요소인 경우 새 값 rPosition 이 로 설정 NULL됩니다.

예시

// Define myList.
CList<CString,CString&> myList;

// Add two elements to the list.
myList.AddHead(CString(_T("ABC")));
myList.AddHead(CString(_T("123")));

// Dump the list elements to the debug window,
// in reverse order.
POSITION pos = myList.GetTailPosition();
for (int i = 0; i < myList.GetCount(); i++)
{
   TRACE(_T("%s\r\n"), (LPCTSTR)myList.GetPrev(pos));
}

CList::GetSize

목록 요소의 수를 반환합니다.

INT_PTR GetSize() const;

Return Value

목록의 항목 수입니다.

설명

이 메서드를 호출하여 목록의 요소 수를 검색합니다. 이 메서드를 호출하면 메서드와 동일한 결과가 CList::GetCount 생성됩니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add two elements to the list.
myList.AddHead(CString(_T("ABC")));
myList.AddHead(CString(_T("123")));

// Remove the head element and verify the list.
// NOTE: once the head is removed, the number of
// elements in the list will be one.
CString strHead = myList.RemoveHead();
ASSERT((CString(_T("123")) == strHead) && (myList.GetSize() == 1) &&
       (CString(_T("ABC")) == myList.GetHead()));

CList::GetTail

이 목록의 CObject tail 요소를 나타내는 포인터를 가져옵니다.

TYPE& GetTail();
const TYPE& GetTail() const;

매개 변수

TYPE
목록의 요소 형식을 지정하는 템플릿 매개 변수입니다.

Return Value

에 대한 GetHead반환 값 설명을 참조하세요.

설명

를 호출 GetTail하기 전에 목록이 비어 있지 않은지 확인해야 합니다. 목록이 비어 있으면 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다. 목록에 요소가 포함되어 있는지 확인하는 데 사용합니다 IsEmpty .

예시

// Define myList.
CList<CString, CString &> myList;

// Add an element to the end of the list.
myList.AddTail(CString(_T("ABC")));

// Verify the element was added to the end of the list.
ASSERT(CString(_T("ABC")) == myList.GetTail());

CList::GetTailPosition

이 목록의 tail 요소 위치를 가져옵니다. NULL 목록이 비어 있으면 입니다.

POSITION GetTailPosition() const;

Return Value

POSITION 목록이 비어 있는 경우 반복 또는 개체 포인터 검색 NULL 에 사용할 수 있는 값입니다.

예시

// Define myList.
CList<CString,CString&> myList;

// Add an element to the end of the list.
myList.AddTail(CString(_T("ABC")));

// Verify the element at the end position
// is the one added.
POSITION pos = myList.GetTailPosition();
ASSERT(CString(_T("ABC")) == myList.GetAt(pos));      

CList::InsertAfter

지정된 위치에 있는 요소 다음에 요소를 이 목록에 추가합니다.

POSITION InsertAfter(POSITION position, ARG_TYPE newElement);

매개 변수

position
이전 GetNext또는 GetPrevFind 멤버 함수 호출에서 반환된 POSITION 값입니다.

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다.

newElement
이 목록에 추가할 요소입니다.

Return Value

POSITION 반복 또는 목록 요소 검색에 사용할 수 있는 값입니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
POSITION pos = myList.AddHead(CString(_T("XYZ")));
pos = myList.InsertAfter(pos, CString(_T("ABC")));
pos = myList.InsertAfter(pos, CString(_T("123")));

// Verify the tail element is what's expected.
ASSERT(CString(_T("123")) == myList.GetTail());

CList::InsertBefore

이 목록에서 지정된 위치의 요소 앞에 요소를 추가합니다.

POSITION InsertBefore(POSITION position, ARG_TYPE newElement);

매개 변수

position
POSITION 이전 GetNext또는 GetPrevFind 멤버 함수 호출에서 반환된 값입니다.

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다(참조일 수 있음).

newElement
이 목록에 추가할 요소입니다.

Return Value

POSITION 반복 또는 목록 요소 검색에 사용할 수 있는 값입니다.

설명

NULL경우 position 요소가 목록의 머리글에 삽입됩니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
POSITION pos = myList.AddHead(CString(_T("XYZ")));
pos = myList.InsertBefore(pos, CString(_T("ABC")));
pos = myList.InsertBefore(pos, CString(_T("123")));

// Verify the head element is what's expected.
ASSERT(CString(_T("123")) == myList.GetHead());

CList::IsEmpty

이 목록에 요소가 없는지 여부를 나타냅니다.

BOOL IsEmpty() const;

Return Value

이 목록이 비어 있으면 0이 아닌 경우 그렇지 않으면 0입니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
myList.AddTail(CString(_T("XYZ")));
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Remove the head element until the list is empty.
CString str;
while (!myList.IsEmpty())
{
   str = myList.RemoveHead();
   TRACE(_T("%s\r\n"), (LPCTSTR)str);
}

CList::RemoveAll

이 목록에서 모든 요소를 제거하고 연결된 메모리를 해제합니다.

void RemoveAll();

설명

목록이 이미 비어 있으면 오류가 생성되지 않습니다.

예시

// Define myList.
CList<CString, CString&> myList;

// Add three elements to the list.
myList.AddTail(CString(_T("XYZ")));
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Remove all of the elements in the list.
myList.RemoveAll();

// Verify the list is empty.
ASSERT(myList.IsEmpty());

CList::RemoveAt

이 목록에서 지정된 요소를 제거합니다.

void RemoveAt(POSITION position);

매개 변수

position
목록에서 제거할 요소의 위치입니다.

설명

값이 POSITION 목록에서 유효한 위치를 나타내는지 확인해야 합니다. 잘못된 경우 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다.

예시

// Define myList.
CList<CString, CString&> myList;

// Add three elements to the list.
myList.AddTail(CString(_T("XYZ")));
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Remove CString("ABC") from the list.
myList.RemoveAt(myList.FindIndex(1));

// Verify CString("ABC") is not in the list.
ASSERT(myList.Find(CString(_T("ABC"))) == NULL);

CList::RemoveHead

목록의 머리에서 요소를 제거하고 해당 요소에 대한 포인터를 반환합니다.

TYPE RemoveHead();

매개 변수

TYPE
목록의 요소 형식을 지정하는 템플릿 매개 변수입니다.

Return Value

목록의 맨 앞에 있는 요소입니다.

설명

를 호출 RemoveHead하기 전에 목록이 비어 있지 않은지 확인해야 합니다. 목록이 비어 있으면 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다. 목록에 요소가 포함되어 있는지 확인하는 데 사용합니다 IsEmpty .

예시

// Define myList.
CList<CString, CString&> myList;

// Add two elements to the list.
myList.AddHead(CString(_T("ABC")));
myList.AddHead(CString(_T("123")));

// Remove the head element and verify the list.
// NOTE: once the head is removed, the number of
// elements in the list will be one.
CString strHead = myList.RemoveHead();
ASSERT((CString(_T("123")) == strHead) && (myList.GetCount() == 1) &&
(CString(_T("ABC")) == myList.GetHead()));

CList::RemoveTail

목록의 꼬리에서 요소를 제거하고 해당 요소에 대한 포인터를 반환합니다.

TYPE RemoveTail();

매개 변수

TYPE
목록의 요소 형식을 지정하는 템플릿 매개 변수입니다.

Return Value

목록의 맨 끝에 있던 요소입니다.

설명

를 호출 RemoveTail하기 전에 목록이 비어 있지 않은지 확인해야 합니다. 목록이 비어 있으면 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다. 목록에 요소가 포함되어 있는지 확인하는 데 사용합니다 IsEmpty .

예시

// Define myList.
CList<CString, CString &> myList;

// Add two elements to the list.
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Remove the tail element and verify the list.
// NOTE: once the tail is removed, the number of
// elements in the list will be one.
CString strTail = myList.RemoveTail();
ASSERT((CString(_T("123")) == strTail) && (myList.GetCount() == 1) &&
       (CString(_T("ABC")) == myList.GetTail()));

CList::SetAt

형식 POSITION 변수는 목록의 키입니다.

void SetAt(POSITION pos, ARG_TYPE newElement);

매개 변수

pos
POSITION 설정할 요소의 요소입니다.

ARG_TYPE
목록 요소의 형식을 지정하는 템플릿 매개 변수입니다(참조일 수 있음).

newElement
목록에 추가할 요소입니다.

설명

인덱스와 동일하지 않으며 직접 값에 POSITION 대해 작업할 수 없습니다. SetAt 는 목록에서 지정된 위치에 요소를 씁니다.

값이 POSITION 목록에서 유효한 위치를 나타내는지 확인해야 합니다. 잘못된 경우 Microsoft Foundation 클래스 라이브러리의 디버그 버전이 어설션됩니다.

예시

// Define myList.
CList<CString, CString &> myList;

// Add three elements to the list.
myList.AddTail(CString(_T("XYZ")));
myList.AddTail(CString(_T("ABC")));
myList.AddTail(CString(_T("123")));

// Replace CString("ABC") with CString("CBA")
POSITION pos = myList.Find(CString(_T("ABC")));
myList.SetAt(pos, CString(_T("CBA")));

// Verify CString("ABC") is not in the list.
ASSERT(myList.Find(CString(_T("ABC"))) == NULL);

참고 항목

MFC 샘플 COLLECT
CObject 클래스
계층 구조 차트
CMap 클래스
CArray 클래스