CList::SetAt
voidSetAt(POSITIONpos**,ARG_TYPEnewElement);**
Parameters
pos
The POSITION of the element to be set.
ARG_TYPE
Template parameter specifying the type of the list element (can be a reference).
newElement
The element to be added to the list.
Remarks
A variable of type POSITION is a key for the list. It is not the same as an index, and you cannot operate on a POSITION value yourself. SetAt writes the element to the specified position in the list.
You must ensure that your POSITION value represents a valid position in the list. If it is invalid, then the Debug version of the Microsoft Foundation Class Library asserts.
Example
// Define myList.
CList<CString,CString&> myList;
// Add three elements to the list.
myList.AddTail(CString("XYZ"));
myList.AddTail(CString("ABC"));
myList.AddTail(CString("123"));
// Replace CString("ABC") with CString("CBA")
POSITION pos = myList.Find(CString("ABC"));
myList.SetAt(pos, CString("CBA"));
// Verify CString("ABC") is not in the list.
ASSERT(myList.Find(CString("ABC")) == NULL);
CList Overview | Class Members | Hierarchy Chart
See Also CList::Find, CList::GetAt, CList::GetNext, CList::GetPrev