Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CList::FindIndex

CList::FindIndex

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

POSITION FindIndex( 
   INT_PTR nIndex  
) const;

nIndex

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

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

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

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

Header: afxtempl.h

Show:
© 2015 Microsoft