Partager via


CList::FindIndex

Uses the value of nIndex as an index into the list.

POSITION FindIndex(
   INT_PTR nIndex 
) const;

Parameters

  • nIndex
    The zero-based index of the list element to be found.

Return Value

A POSITION value that can be used for iteration or object pointer retrieval; NULL if nIndex is negative or too large.

Remarks

It starts a sequential scan from the head of the list, stopping on the nth element.

Example

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

Requirements

Header: afxtempl.h

See Also

Concepts

CList Class

CList Members

Hierarchy Chart

CObList::Find

CObList::GetNext

CObList::GetPrev