CList::SetAt

类型 POSITION 的变量是列表的密钥。

void SetAt(
   POSITION pos,
   ARG_TYPE newElement 
);

参数

  • pos
    要设置的元素的 POSITION

  • ARG_TYPE
    指定列表元素的类型模板参数(可以是引用)。

  • newElement
    要添加的元素到列表中。

备注

这不是同样作为索引,因此,您不能对 POSITION 值。SetAt 写入指定的位置的元素在列表中。

您必须确保 POSITION 值表示列表中的有效位置。如果是无效的,则选件Microsoft基础类库的调试版本断言。

示例

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

// Replace CString("ABC") with CString("CBA")
POSITION pos = myList.Find(CString(_T("ABC")));
myList.SetAt(pos, CString(_T("CBA")));

// Verify CString("ABC") is not in the list.
ASSERT(myList.Find(CString(_T("ABC"))) == NULL);      

要求

Header: afxtempl.h

请参见

参考

CList选件类

层次结构图

CList::Find

CList::GetAt

CList::GetNext

CList::GetPrev