Partager via


CAtlList::AddHead

Call this method to add an element to the head of the list.

POSITION AddHead( ); 
POSITION AddHead( 
   INARGTYPE element  
);

Parameters

  • element
    The new element.

Return Value

Returns the position of the newly added element.

Remarks

If the first version is used, an empty element is created using its default constructor, rather than its copy constructor.

Example

// Declare a list of integers
CAtlList<int> myList;

// Add some elements, each to the head of the list. 
// As each new element is added, the previous head is 
// pushed down the list.
myList.AddHead(42);
myList.AddHead(49);

// Confirm the value currently at the head of the list
ATLASSERT(myList.GetHead() == 49);

// Confirm the value currently at the tail of the list
ATLASSERT(myList.GetTail() == 42);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlList Class

CAtlList::AddHeadList

CAtlList::AddTail