Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The CBaseListclass represents a list of pointers to objects. No storage management or copying is done on the objects that are pointed to.
The implementation allows for objects to be on multiple lists simultaneously and does not require support in the objects themselves; therefore, it is particularly useful for holding variable-length lists of interface pointers.
The implementation is not multithread safe. External locks are required to maintain the integrity of the list when it is accessed from more than one thread simultaneously.
The POSITIONstructure represents a position in a linked list that is actually a void pointer. A position represents a cursor on the list that can be set to identify any element. NULL is a valid value, and several operations regard NULL as the position that is "one step off the end of the list." (In an nelement list there are n+1 places to insert, and NULL is that n+1 value.) The position of an element in the list is only invalidated if that element is deleted. Move operations might indicate that what was a valid position in one list is now a valid position in a different list.
Some operations, which at first sight seem illegal, are allowed as harmless null operations (no-ops). For example, the CBaseList::RemoveHeadImember function is legal on an empty list, and it returns NULL. This allows an atomic way to test if there is an element there and, if so, to retrieve it.
Single-element operations return positions, where a non-NULL value indicates that it worked. Entire list operations return a Boolean value, where TRUE indicates success.
Protected Data Members
m_Count | Number of nodes in the list. |
m_pFirst | Pointer to the first node in the list. |
m_pLast | Pointer to the last node in the list. |
Member Functions
AddAfter | Inserts a list of nodes after the specified node. |
AddAfterI | Inserts a node after the specified node. |
AddBefore | Inserts a list of nodes before the specified node. |
AddBeforeI | Inserts a node before the specified node. |
AddHead | Inserts a list of nodes at the front of the list. |
AddHeadI | Inserts a node at the front of the list. |
AddTail | Appends a list of nodes to the end of the list. |
AddTailI | Appends a node to the end of the list. |
CBaseList | Constructs a CBaseListobject. |
FindI | Returns the first position that holds the specified object. |
GetCountI | Returns the number of objects in the list. |
GetHeadPositionI | Returns a cursor identifying the first element of the list. |
GetI | Returns the object at the specified position. |
GetNextI | Returns the specified object and updates the position. |
GetTailPositionI | Returns a cursor identifying the last element of the list. |
MoveToHead | Moves the node or list of nodes to the beginning of a second list. |
MoveToTail | Moves the node or list of nodes to the end of a second list. |
Next | Returns the next position in the list. |
Prev | Returns the previous position in the list. |
RemoveAll | Removes all nodes from the list. |
RemoveHeadI | Removes the first node in the list. |
RemoveI | Removes the specified node from the list. |
RemoveTailI | Removes the last node in the list. |
Reverse | Reverses the order of the pointers to the objects in the list. |