CObList::AddHead

添加一个新元素或列表元素到此开头的列表。

POSITION AddHead(
   CObject* newElement 
);
void AddHead(
   CObList* pNewList 
);

参数

  • newElement
    要添加的 CObject 指向此列表。

  • pNewList
    到另一 CObList 的指针列表。 在 pNewList 的组件将添加到此列表。

返回值

第一个版本返回新插入的元素的 POSITION 值。

下表显示类似于 CObList::AddHead的其他成员函数。

成员函数

CPtrList

POSITION AddHead( void* newElement);

void AddHead( CPtrList* pNewList);

CStringList

POSITION AddHead(const CString& newElement);

POSITION AddHead(LPCTSTR newElement);

void AddHead(CStringList* pNewList);

备注

该列表可为null在操作之前。

示例

用于列表 CAge 选件类参见 CObList::CObList

CObList list;
list.AddHead(new CAge(21)); // 21 is now at head.
list.AddHead(new CAge(40)); // 40 replaces 21 at head.
#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << _T("AddHead example: ") << &list << _T("\n");
#endif      

从此过程的结果如下:

AddHead example: A CObList with 2 elements

a CAge at $44A8 40

a CAge at $442A 21

要求

Header: afxcoll.h

请参见

参考

CObList选件类

层次结构图

CObList::GetHead

CObList::RemoveHead