Поделиться через


CAtlList::InsertBefore

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

POSITION InsertBefore(
   POSITION pos,
   INARGTYPE element 
);

Параметры

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

  • element
    The element to be inserted.

Возвращаемое значение

Returns the POSITION value of the new element.

Заметки

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.

Пример

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

Требования

Header: atlcoll.h

См. также

Основные понятия

CAtlList Class

CAtlList Members

CAtlList::InsertAfter