Freigeben über


CList::AddHead

Adds a new element or list of elements to the head of this list.

POSITION AddHead(
      ARG_TYPE newElement 
);
void AddHead(
   CList* pNewList 
);

Parameters

  • ARG_TYPE
    Template parameter specifying the type of the list element (can be a reference).

  • newElement
    The new element.

  • pNewList
    A pointer to another CList list. The elements in pNewList will be added to this list.

Return Value

The first version returns the POSITION value of the newly inserted element.

Remarks

The list can be empty before the operation.

Example

// Declarations of the variables used in the example
CList<CString,CString&> myList;
CList<CString,CString&> myList2;

// There are two versions of CList::AddHead: one adds a single
// element to the front of the list, the second adds another list
// to the front. 

// This adds the string "ABC" to the front of myList.
// myList is a list of CStrings (ie defined as CList<CString,CString&>).
myList.AddHead(CString(_T("ABC")));

// This adds the elements of myList2 to the front of myList.
myList.AddHead(&myList2);      

Requirements

Header: afxtempl.h

See Also

Concepts

CList Class

CList Members

Hierarchy Chart

CList::GetHead

CList::RemoveHead