CObList::Find

循序搜尋清單中尋找第一 CObject 指標符合指定的 CObject 指標。

POSITION Find(
   CObject* searchValue,
   POSITION startAfter = NULL 
) const;

參數

  • searchValue
    在這份清單中找到的物件指標。

  • startAfter
    搜尋的開始位置。

傳回值

可以針對反覆項目或物件指標擷取使用的 位置 值; NULL ,如果找不到物件。

備註

請注意指標值比較,不會比較物件的內容。

下表顯示類似 CObList::Find的其他成員函式。

類別

成員函式

CPtrList

POSITION Find( void* searchValue, POSITION startAfter = NULL ) const;

CStringList

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

範例

提供 CAge 類別的目錄參閱 CObList::CObList

CObList list;
CAge* pa1;
CAge* pa2;
POSITION pos;
list.AddHead(pa1 = new CAge(21));
list.AddHead(pa2 = new CAge(40));    // List now contains (40, 21).
if ((pos = list.Find(pa1)) != NULL) // Hunt for pa1
{                                  // starting at head by default.
    ASSERT(*(CAge*) list.GetAt(pos) == CAge(21));
}    

需求

Header: afxcoll.h

請參閱

參考

CObList 類別

階層架構圖

CObList::GetNext

CObList::GetPrev