Compartilhar via


CAtlList::InsertBefore

Call this method to insert a new element into the list before the specified position.

POSITION InsertBefore(
   POSITION pos,
   INARGTYPE element 
);

Parameters

  • pos
    The new element will be inserted into the list before this POSITION value.

  • element
    The element to be inserted.

Return Value

Returns the POSITION value of the new element.

Remarks

In debug builds, an assertion failure will occur if the list isn't valid, if the insert fails, or if an attempt is made to insert the element before the head.

Example

// Define the integer list
CAtlList<int> myList;

// Populate the list
POSITION myPos = myList.AddHead(1);
myPos = myList.InsertBefore(myPos, 2);
myPos = myList.InsertBefore(myPos, 3);

// Confirm the head value is as expected
ATLASSERT(myList.GetHead() == 3);  

Requirements

Header: atlcoll.h

See Also

Reference

CAtlList Class

CAtlList::InsertAfter

Other Resources

CAtlList Members