#include <list.h>
Inheritance diagram for LIST< T >:
Public Types | |
typedef LIST::LIST_TYPE | list_type |
typedef list_type * | handle |
Public Member Functions | |
LIST (void) | |
void | dealloc (void) |
deallocate the list | |
void | add (T data) |
void | reverse (void) |
unsigned int | length (void) |
return the lenght of the list | |
handle | remove (void) |
remove an element from the start of the list and return the first element of the remaining list | |
T | get_item (handle h) |
given a handle, return the associated data item | |
handle | first (void) |
get the first element from the list | |
handle | next (handle h) |
iterator to get the next element | |
Private Attributes | |
list_type * | list |
It should be instantiated with a scalar type, like an integer or a pointer to a larger type (e.g., a string or a structure). For example
LIST<char *> list; LIsT<my_struct *> list;
This class does not have anything but the default destructor. In order to allow a function to allocate a list and then return the list as its result, the list is not deallocated by the destructor. The list can be deallocated by calling the "dealloc" class function.
Definition at line 36 of file list.h.
|
|
|
|
|
Definition at line 51 of file list.h.
00052 { 00053 list = 0; 00054 } |
|
Definition at line 65 of file list.h.
|
|
deallocate the list
Definition at line 58 of file list.h.
00059 { 00060 while ( remove() != 0 ) 00061 /* nada */; 00062 } // dealloc |
|
get the first element from the list
Definition at line 136 of file list.h.
00137 { 00138 return list; 00139 } // first |
|
given a handle, return the associated data item
Definition at line 128 of file list.h.
00129 { 00130 00131 return h->data; 00132 } // get_item |
|
return the lenght of the list
Definition at line 99 of file list.h.
|
|
iterator to get the next element
Definition at line 143 of file list.h. Referenced by LIST< type_time * >::reverse().
|
|
remove an element from the start of the list and return the first element of the remaining list
Definition at line 114 of file list.h. Referenced by LIST< type_time * >::dealloc().
|
|
Definition at line 83 of file list.h.
|
|
Definition at line 45 of file list.h. Referenced by LIST< type_time * >::add(), symtable::dealloc_sub_tables(), LIST< type_time * >::first(), LIST< type_time * >::length(), LIST< type_time * >::LIST(), symtable::pr(), strtable::pr(), LIST< type_time * >::remove(), and LIST< type_time * >::reverse(). |