CObList::FindIndex

使用 nIndex 的值作为索引到列表中。

POSITION FindIndex( 
   INT_PTR nIndex  
) const;

参数

  • nIndex
    将找到的列表元素的从零开始的索引。

返回值

可以为迭代或对象指针检索使用的 POSITION 值; NULL,如果 nIndex 太大。 (framework生成断言,如果 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 Class

层次结构图

CObList::Find

CObList::GetNext

CObList::GetPrev