#include <tlist.h>
Inheritance diagram for tutk::List< T >:
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. | |
T | getLastNode (bool &validity) |
Returns the data in the last node of the list. | |
T | 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. |
|
Default Constructor. Data is partially or fully prone to multiple references as the copy constructor is only be a reference copier. |
|
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.
After the above code snippet is executed, size of l1 is 1, where as size of l2 is still 0. |
|
Destructor. It does consider the number of references to the object before destruction. |
|
Appends a node to the end of the list. It is equivalent to push. |
|
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. |
|
Returns the data in the last node of the list. The parameter validity will hold true on success and false on failure. |
|
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. |
|
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. |
|
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. |
|
Pops a node from the end of the list.
Does nothing in case of an empty list. |
|
Pushes a node to the end of the list. It is equivalent to append. Infact push calls the function append. |
|
Resets the currentNodePtr. See the description of the getNode member function below for more information. |