CBaseList Class (Compact 2013)
3/26/2014
CBaseList Class
This class 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 POSITION structure represents a position in a linked list that is 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 n element 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::RemoveHeadI member 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
Member |
Description |
---|---|
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
Member function |
Description |
---|---|
Inserts a list of nodes after the specified node. |
|
Inserts a node after the specified node. |
|
Inserts a list of nodes before the specified node. |
|
Inserts a node before the specified node. |
|
Inserts a list of nodes at the front of the list. |
|
Inserts a node at the front of the list. |
|
Appends a list of nodes to the end of the list. |
|
Appends a node to the end of the list. |
|
Constructs a CBaseList object. |
|
Returns the first position that holds the specified object. |
|
Returns the number of objects in the list. |
|
Returns a cursor identifying the first element of the list. |
|
Returns the object at the specified position. |
|
Returns the specified object and updates the position. |
|
Returns a cursor identifying the last element of the list. |
|
Moves the node or list of nodes to the beginning of a second list. |
|
Moves the node or list of nodes to the end of a second list. |
|
Returns the next position in the list. |
|
Returns the previous position in the list. |
|
Removes all nodes from the list. |
|
Removes the first node in the list. |
|
Removes the specified node from the list. |
|
Removes the last node in the list. |
|
Reverses the order of the pointers to the objects in the list. |
Requirements
Header |
dshow.h, |
Library |
ole32.lib, |