CObList::FindIndex

使用 nIndex 內的值當做索引清單。

POSITION FindIndex(
   INT_PTR nIndex 
) const;

參數

  • nIndex
    要尋找之清單項目的以零起始的索引。

傳回值

可以針對反覆項目或物件指標擷取使用的 位置 值; NULL ,如果 nIndex 太大。(Frame 產生判斷提示 nIndex 是否為負值)。

備註

啟動執行掃描 清單的開頭,停止在 第 n 個項目。

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

類別

成員函式

CPtrList

POSITION FindIndex( INT_PTR nIndex ) const;

CStringList

POSITION FindIndex( INT_PTR nIndex ) const;

範例

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

CObList list;
POSITION pos;

list.AddHead(new CAge(21));
list.AddHead(new CAge(40)); // List now contains (40, 21).
if ((pos = list.FindIndex(0)) != NULL)
{
    ASSERT(*(CAge*) list.GetAt(pos) == CAge(40));
}    

需求

Header: afxcoll.h

請參閱

參考

CObList 類別

階層架構圖

CObList::Find

CObList::GetNext

CObList::GetPrev