chrono::ChList< dt > Class Template Reference

Description

template<class dt>
class chrono::ChList< dt >

Class for linked list.

This linked list class can be used to build lists of pointers to objects. This has a different meaning from STL lists (which are lists of objects), because ours can manage the deletion of all pointed objects.

#include <ChLists.h>

Public Member Functions

 ChList ()
 Constructor.
 
 ~ChList ()
 Deletion.
 
dt * GetHeadData ()
 Returns the data at the head of the list.
 
dt * GetTailData ()
 Returns the data at the tail of the list.
 
ChNode< dt > * GetHead ()
 Returns the head node.
 
ChNode< dt > * GetTail ()
 Returns the tail node.
 
ChNode< dt > * GetNum (int num)
 Returns a node at given position in list. More...
 
void AddHead (dt *mdata)
 Insert data at the head of the list.
 
void AddTail (dt *mdata)
 Insert data at the tail of the list.
 
bool RemHead ()
 Removes the head of list.
 
bool RemTail ()
 Removes the tail of list.
 
void InsertAfter (ChNode< dt > *mnode, ChNode< dt > *newnode)
 
void InsertBefore (ChNode< dt > *mnode, ChNode< dt > *newnode)
 
void InsertAfter (ChNode< dt > *mnode, dt *mdata)
 
void InsertBefore (ChNode< dt > *mnode, dt *mdata)
 
void Remove (ChNode< dt > *mnode)
 Removes a node. More...
 
void RemoveAll ()
 Removes all nodes.
 
void Kill (ChNode< dt > *mnode)
 Removes a node and deletes its data. More...
 
void KillAll ()
 Kills all nodes.
 
int Count ()
 Returns number of elements in list.
 

Member Function Documentation

template<class dt >
ChNode< dt > * chrono::ChList< dt >::GetNum ( int  num)

Returns a node at given position in list.

Returns null if num exceeds num of nodes. Note: num=1 gets first element,

template<class dt>
void chrono::ChList< dt >::Kill ( ChNode< dt > *  mnode)

Removes a node and deletes its data.

Note the Kill() commands remove and also use delete(data) to free the objects pointed by nodes!,

template<class dt>
void chrono::ChList< dt >::Remove ( ChNode< dt > *  mnode)

Removes a node.

Note the Remove() command delete just the Ch_node, not the pointed 'data' object