#include <LinkedList.h>
Inheritance diagram for LinkedList::

Public Methods | |
| LinkedList () | |
| Empty constructor, which sets up an empty linked list. | |
| virtual | ~LinkedList () |
| Destructor. More... | |
| ListItem< T > * | find (T &data) |
Find the ListItem with value data in the list. More... | |
| ListItem< T > * | head () const |
| Returns the head of the linked list. | |
| ListItem< T > * | tail () const |
| Returns the tail of the linked list. | |
| ListItem< T > * | next (ListItem< T > *item) const |
| Returns the next item in the list after item. | |
| T & | top () |
| Returns the value of the next item that will be removed. | |
| void | add (T &data) |
| Adds a list item with data value data. | |
| void | add (T &data, ListItem< T > *&item) |
Adds a list item with data value data, and returns the ListItem object in the item argument. | |
| ListItem< T > * | insert (T &data, ListItem< T > *item=(ListItem< T > *) 0) |
| Insert an item in the list with data value data. More... | |
| void | remove (T &data) |
| Removes the next list item and returns the data value in data. | |
| void | remove (ListItem< T > *item) |
| Removes item from the list. | |
| void | remove (ListItem< T > *item, T &data) |
| Removes item from the list and returns the data value in data. | |
| int | empty () const |
Returns TRUE if the list is empty and FALSE otherwise. | |
| operator int () const | |
Returns TRUE if the list is empty and FALSE otherwise. | |
| int | size () const |
| Returns the length of the list. | |
| int | len () const |
| Returns the length of the list. (deprecated). | |
| void | stack_mode () |
| Sets the add/remove mode to operate a stack. | |
| void | queue_mode () |
| Sets the add/remove mode to operate a queue (the default). | |
Protected Types | |
| enum | { stackLL = 0, queueLL = 1 } |
Defines the different modes that the LinkedList can operate. More... | |
Protected Methods | |
| void | extract (ListItem< T > *item) |
| Removes an item from the list. | |
| void | extract (ListItem< T > *item, T &data) |
| Removes an item from the list and returns its value in data. | |
Protected Attributes | |
| int | mode |
| The add/remove mode. | |
| ListItem< T > * | first |
| The first item in the list. | |
| ListItem< T > * | last |
| The last item in the list. | |
| int | Len |
| The length of the list. | |
Static Protected Attributes | |
| int | counter = 0 |
The number of unused ListItem objects. | |
The design of this class was strongly influenced by Stanley B. Lippman, "C++ Primer, 2nd Edition." Addison Wesley, 1991. This linked list code can be switched between use as a queue, stack or simple linked list by setting different `mode' values. By default, a LinkedList object behaves like a queue.
|
|||||
|
Defines the different modes that the
|
|
|||||||||
|
Destructor.
After deleting the list, the destructor deletes the list of additional unused |
|
||||||||||
|
Find the
If this data value is not found in the list, this method returns |
|
||||||||||||||||
|
Insert an item in the list with data value data. If item is not null, then the new item is inserted before next. Otherwise, it is inserted at the end of the list. |