CGenericList Class

CGenericList class hierarchy

CGenericList is a template class that allows for a type-specific implementation of a list. It is derived from CBaseList and uses that class's typeless implementation. The constructor creates a CBaseList object, and all CGenericList member functions call CBaseList member functions but provide type-checking dependent on the template.

Member Functions

AddAfter Inserts a node or list of nodes after the specified node.
AddBefore Inserts a node or list of nodes before the specified node.
AddHead Inserts a node or list of nodes at the front of the list.
AddTail Appends a node or list of nodes to the end of the list.
CGenericList Constructs a CGenericList object.
Find Retrieves the first position that contains the specified object.
Get Retrieves the object at the specified position.
GetCount Retrieves the number of objects (object count) in the list.
GetHead Retrieves the object at the head of the list.
GetHeadPosition Retrieves a cursor identifying the first element of the list.
GetNext Retrieves the specified object and update position.
GetTailPosition Retrieves a cursor identifying the last element of the list.
Remove Removes the specified node from the list.
RemoveHead Removes the first node in the list.
RemoveTail Removes the last node in the list.

CGenericList::AddAfter

CGenericList Class

Inserts a node or list of nodes after the specified node.

Syntax

POSITION AddAfter(
    POSITION p,
    OBJECT *pObj
    );
BOOL AddAfter(
    POSITION pos,
    CGenericList<OBJECT> *pList
    );

Parameters

p
Position after which to add the node.
pObj
Pointer to the object to add.
pos
Position after which to add the list of nodes.
pList
Pointer to the list of objects to add.

Return Value

Returns the position of the inserted object in the case of single-object insertion. For list insertion, returns TRUE if successful; otherwise, returns FALSE.

Remarks

This member function calls the CBaseList::AddAfter member function when passed a list of nodes. CGenericList::AddAfter calls the CBaseList::AddAfterI member function when passed a single node.

CGenericList::AddBefore

CGenericList Class

Inserts a node or list of nodes before the specified node.

Syntax

POSITION AddBefore(
    POSITION p,
    OBJECT *pObj
    );
BOOL AddBefore(
    POSITION pos,
    CGenericList<OBJECT> *pList
    );

Parameters

p
Position before which to add the node.
pObj
Pointer to the object to add.
pos
Position before which to add the list of nodes.
pList
Pointer to the list of objects to add.

Return Value

Returns the position of the inserted object in the case of single-object insertion. For list insertion, returns TRUE if successful; otherwise, returns FALSE.

Remarks

This member function calls the CBaseList::AddBefore member function when passed a list of nodes. CGenericList::AddBefore calls the CBaseList::AddBeforeI member function when passed a single node.

CGenericList::AddHead

CGenericList Class

Inserts a node or list of nodes at the front of the list.

Syntax

POSITION AddHead(
    OBJECT *pObj
    );
BOOL AddHead(
    CGenericList<OBJECT> *pList
    );

Parameters

pObj
Pointer to the object to add.
pList
Pointer to the list of objects to add.

Return Value

Returns the new head position, or NULL if unsuccessful in the case of single-node additions. For list insertions, returns TRUE if successful; otherwise, returns FALSE.

Remarks

This member function calls the CBaseList::AddHead member function when passed a list of nodes. CGenericList::AddHead calls the CBaseList::AddHeadI member function when passed a single node.

CGenericList::AddTail

CGenericList Class

Appends a node or list of nodes to the end of the list.

Syntax

POSITION AddTail(
    OBJECT *pObj
    );
BOOL AddTail(
    CGenericList<OBJECT> *pList
    );

Parameters

pObj
Pointer to the object to add.
pList
Pointer to the list of objects to add.

Return Value

Returns the new tail position, or NULL if unsuccessful in the case of single-node insertions. For list insertions, returns TRUE if successful; otherwise, returns FALSE.

Remarks

This member function calls the CBaseList::AddTail member function when passed a list of nodes. CGenericList::AddTail calls the CBaseList::AddTailI member function when passed a single node.

CGenericList::CGenericList

CGenericList Class

Constructs a CGenericList object.

Syntax

CGenericList(
    TCHAR *pName,
    INT iItems,
    BOOL bLock,
    BOOL bAlert
    );
CGenericList(
    TCHAR *pName
    );

Parameters

pName
Pointer to the name of the list.
iItems
Number of items in the list.
bLock
Value indicating whether the list is locked; TRUE if the list is locked or FALSE otherwise. This parameter defaults to TRUE.
bAlert
Not used.

Return Value

No return value.

Remarks

This constructor calls the CBaseList constructor.

CGenericList::Find

CGenericList Class

Retrieves the first position that contains the specified object.

Syntax

POSITION Find(
    OBJECT *pObj
    );

Parameters

pObj
Pointer to the object to find.

Return Value

Returns a position cursor.

Remarks

This member function calls the CBaseList::FindI member function.

CGenericList::Get

CGenericList Class

Retrieves the object at the specified position.

Syntax

OBJECT *Get(
    POSITION pos
    );

Parameters

pos
Position in the list from which to retrieve the object.

Return Value

Returns a pointer to an object.

Remarks

This member function calls the CBaseList::GetI member function.

CGenericList::GetCount

CGenericList Class

Retrieves the number of objects (object count) in the list.

Syntax

int GetCount(void);

Return Value

Returns the value of m_Count.

CGenericList::GetHead

CGenericList Class

Retrieves the object at the head of the list.

Syntax

OBJECT GetHead(void);

Return Value

Returns the head of the list by calling CGenericList::GetHeadPosition.

CGenericList::GetHeadPosition

CGenericList Class

Retrieves a cursor identifying the first element of the list.

Syntax

POSITION GetHeadPosition(void);

Return Value

Returns the position cursor held by m_pFirst.

CGenericList::GetNext

CGenericList Class

Retrieves the specified object and update position.

Syntax

OBJECT *GetNext(
    POSITION& rp
    );

Parameters

rp
Returned pointer to the next object.

Return Value

Returns a pointer to an object at the next position.

Remarks

This member function calls the CBaseList::GetNextI member function.

CGenericList::GetTailPosition

CGenericList Class

Retrieves a cursor identifying the last element of the list.

Syntax

POSITION GetTailPosition(void);

Return Value

Returns the position cursor held by m_pLast.

CGenericList::Remove

CGenericList Class

Removes the specified node from the list.

Syntax

OBJECT *Remove(
    POSITION pos
    );

Parameters

pos
Position in the list of nodes to remove.

Return Value

Returns the pointer to the object that was removed.

Remarks

This member function calls the CBaseList::RemoveI member function.

CGenericList::RemoveHead

CGenericList Class

Removes the first node in the list.

Syntax

OBJECT *RemoveHead(void);

Return Value

Returns the pointer to the object that was removed.

Remarks

This member function calls the CBaseList::RemoveHeadI member function.

CGenericList::RemoveTail

CGenericList Class

Removes the last node in the list.

Syntax

OBJECT *RemoveTail(void);

Return Value

Returns the pointer to the object that was removed.

Remarks

This member function calls the CBaseList::RemoveTailI member function.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.