Поделиться через


CList::Find

Searches the list sequentially to find the first element matching the specified searchValue.

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

Параметры

  • ARG_TYPE
    Template parameter specifying the type of the list element (can be a reference).

  • searchValue
    The value to be found in the list.

  • startAfter
    The start position for the search. If no value is specified, the search begins with the head element.

Возвращаемое значение

A POSITION value that can be used for iteration or object pointer retrieval; NULL if the object is not found.

Пример

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

Требования

Header: afxtempl.h

См. также

Основные понятия

CList Class

CList Members

Hierarchy Chart

CList::GetNext

CList::GetPrev