#include <fifo_list.h>
Inheritance diagram for FIFO_LIST< T >:
Public Types | |
typedef FIFO_LIST::LIST_TYPE | list_type |
typedef list_type * | handle |
Public Member Functions | |
FIFO_LIST (void) | |
void | dealloc (void) |
deallocate the list | |
void | add (T data) |
void | reverse (void) |
reverse the list | |
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 |
list_type * | tail |
In this list, items are added to the tail. When read from the front of the list, items will be read in a first-in, first-out order. In contrast, the LIST template class adds items to the head and reads from the head (last in, first out). 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
FIFO_LIST<char *> list; FIFO_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 45 of file fifo_list.h.
Member Typedef Documentation
|
Definition at line 58 of file fifo_list.h. |
|
|
|
Definition at line 61 of file fifo_list.h.
|
|
Definition at line 75 of file fifo_list.h.
|
|
deallocate the list
Definition at line 68 of file fifo_list.h.
|
|
get the first element from the list
Definition at line 152 of file fifo_list.h.
00153 { 00154 return list; 00155 } // first |
|
given a handle, return the associated data item
Definition at line 144 of file fifo_list.h.
00145 { 00146 00147 return h->data; 00148 } // get_item |
|
return the lenght of the list
Definition at line 111 of file fifo_list.h.
|
|
iterator to get the next element
Definition at line 159 of file fifo_list.h. Referenced by FIFO_LIST< pSym >::reverse().
|
|
remove an element from the start of the list and return the first element of the remaining list
Definition at line 126 of file fifo_list.h. Referenced by FIFO_LIST< pSym >::dealloc().
|
|
reverse the list
Definition at line 94 of file fifo_list.h.
|
|
Definition at line 54 of file fifo_list.h. Referenced by FIFO_LIST< pSym >::add(), FIFO_LIST< pSym >::FIFO_LIST(), FIFO_LIST< pSym >::first(), FIFO_LIST< pSym >::length(), FIFO_LIST< pSym >::remove(), and FIFO_LIST< pSym >::reverse(). |
|
Definition at line 55 of file fifo_list.h. Referenced by FIFO_LIST< pSym >::add(), FIFO_LIST< pSym >::FIFO_LIST(), FIFO_LIST< pSym >::remove(), and FIFO_LIST< pSym >::reverse(). |