Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members

tutk::List< T > Class Template Reference

#include <tlist.h>

Inheritance diagram for tutk::List< T >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<class T>
class tutk::List< T >

Class List.

Class implementing a linked list with two way traversal.


Public Member Functions

 List (void)
 Default Constructor.

 List (const List &l)
 Copy constructor.

 ~List ()
 Destructor.

void append (T node)
 Appends a node to the end of the list.

void push (T node)
 Pushes a node to the end of the list.

void pop (void)
 Pops a node from the end of the list.

void destroy (void)
 Destroys the list.

void refresh (void)
 Resets the currentNodePtr.

getLastNode (bool &validity)
 Returns the data in the last node of the list.

getNode (bool &validity)
 Returns the current node.

T * getPointerToNodeItem (void)
 Returns a pointer the node data item pointed to by the currentNodePtr.

int getSize (void)
 Returns the number of data nodes in the list.

T * getPointerToLastItem (void)
 Returns a pointer to the last data item in the list.

void operator= (const List &l)
 Assignment operator.


Constructor & Destructor Documentation

template<class T>
tutk::List< T >::List void   ) 
 

Default Constructor.

Data is partially or fully prone to multiple references as the copy constructor is only be a reference copier.

template<class T>
tutk::List< T >::List const List< T > &  l  ) 
 

Copy constructor.

It is only a reference copier. But the user should keep in mind that passing an empty object to a function would result in a call by value, where as passing a non-empty object would result in call by reference.

The user should also keep in mind that empty objects will not be copied by reference. i.e. copy construction using an empty object followed by data creation would lead to objects have different data-space in memory.

List< T > l1;
List< T > l2(l1);
l1.append(T);

After the above code snippet is executed, size of l1 is 1, where as size of l2 is still 0.

template<class T>
tutk::List< T >::~List  ) 
 

Destructor.

It does consider the number of references to the object before destruction.


Member Function Documentation

template<class T>
void tutk::List< T >::append node  ) 
 

Appends a node to the end of the list.

It is equivalent to push.

template<class T>
void tutk::List< T >::destroy void   ) 
 

Destroys the list.

All the memory held by the list is destroyed. Care has to be taken in using this method when the list data has multiple references. In case of an object with multiple references is destroyed to empty-ness, then the multiple references would no longer hold. Each individual object would have its own data in memory on subsequent refilling of the object.

template<class T>
T tutk::List< T >::getLastNode bool &  validity  ) 
 

Returns the data in the last node of the list.

The parameter validity will hold true on success and false on failure.

template<class T>
T tutk::List< T >::getNode bool &  validity  ) 
 

Returns the current node.

The list implmentation has a private data member called currentNodePtr which points to the first node on creation of a list object. With each call to this function the the data of the node to which the currentNodePtr points to is returned and the currentNodePtr is moved to the next node in the list. A call to the member function refresh resets the currentNodePtr to the first node of the list.

template<class T>
T * tutk::List< T >::getPointerToNodeItem void   ) 
 

Returns a pointer the node data item pointed to by the currentNodePtr.

It is same as getNode in its operation but for the type of data returned. This function does not update the currentNodePtr to the next node.

template<class T>
void tutk::List< T >::operator= const List< T > &  l  ) 
 

Assignment operator.

It is only a reference copier. i.e., after an assignment operation, the l-value and the r-value share the same data.

template<class T>
void tutk::List< T >::pop void   ) 
 

Pops a node from the end of the list.

Does nothing in case of an empty list.
In case of an object with multiple references is pop-ed out to empty-ness, then the multiple references would no longer hold. Each individual object would have its own data in memory on subsequent refilling of the object.

template<class T>
void tutk::List< T >::push node  ) 
 

Pushes a node to the end of the list.

It is equivalent to append. Infact push calls the function append.

template<class T>
void tutk::List< T >::refresh void   ) 
 

Resets the currentNodePtr.

See the description of the getNode member function below for more information.


The documentation for this class was generated from the following file:
Generated on Mon Nov 22 11:12:42 2004 for ImprolaLib by doxygen 1.3.7