CPtrList : CObject
The CPtrList class supports lists of void pointers.
The member functions of CPtrList are similar to the member functions of class CObList. Because of this similarity, you can use the CObList reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a pointer to void.
CObject*& CObList::GetHead() const;
for example, translates to
void*& CPtrList::GetHead() const;
CPtrList incorporates the IMPLEMENT_DYNAMIC macro to support run-time type access and dumping to a CDumpContext object. If you need a dump of individual pointer list elements, you must set the depth of the dump context to 1 or greater.
Pointer lists cannot be serialized.
When a CPtrList object is deleted, or when its elements are removed, only the pointers are removed, not the entities they reference.
For more information on using CPtrList, see the articleCollections in Visual C++ Programmer’s Guide.
#include <afxcoll.h>
CPtrList Class Members
Construction
CPtrList | Constructs an empty list for void pointers. 构建空指针的空列表。 |
Head/Tail Access
GetHead | Returns the head element of the list (cannot be empty). 返回列表的头元素(不能为空)。 |
GetTail | Returns the tail element of the list (cannot be empty). 返回列表的尾部元素(不能为空)。 |
Operations
RemoveHead | Removes the element from the head of the list. |
RemoveTail | Removes the element from the tail of the list. |
AddHead | Adds an element (or all the elements in another list) to the head of the list (makes a new head). 增加一个元素到表头(或其他列表中的所有元素添加到列表的头)(成为一个新的头)。 |
AddTail | Adds an element (or all the elements in another list) to the tail of the list (makes a new tail). 增加一个元素到表尾(或其他列表中的所有元素添加到列表的头)(成为一个新的尾)。 |
RemoveAll | Removes all the elements from this list. |
Iteration
GetHeadPosition | Returns the position of the head element of the list. 返回列表的头元素的位置。 |
GetTailPosition | Returns the position of the tail element of the list. 返回列表的尾部元素的位置。 |
GetNext | Gets the next element for iterating. 获取用于迭代的下一个元素。 |
GetPrev | Gets the previous element for iterating. 获取迭代的前一个元素。 |
Retrieval/Modification
GetAt | Gets the element at a given position. |
SetAt | Sets the element at a given position. |
RemoveAt | Removes an element from this list, specified by position. |
Insertion
InsertBefore | Inserts a new element before a given position. |
InsertAfter | Inserts a new element after a given position. |
Searching
Find | Gets the position of an element specified by pointer value. 获取由指针值指定的元素的位置。 |
FindIndex | Gets the position of an element specified by a zero-based index. |
Status
GetCount | Returns the number of elements in this list. |
IsEmpty | Tests for the empty list condition (no elements). |