#include <list.h>
Public Methods | |
| List () | |
| ~List () | |
| void | Prepend (void *item) |
| void | Append (void *item) |
| void * | Remove () |
| void | Mapcar (VoidFunctionPtr func) |
| bool | IsEmpty () |
| void | SortedInsert (void *item, int sortKey) |
| void * | SortedRemove (int *keyPtr) |
Private Attributes | |
| ListElement * | first |
| ListElement * | last |
|
|
Definition at line 43 of file list.cc. References first, last, and NULL.
|
|
|
Definition at line 58 of file list.cc.
|
|
|
Definition at line 77 of file list.cc. References first, IsEmpty, last, and ListElement::next. Referenced by SynchList::Append, Semaphore::P, and Scheduler::ReadyToRun.
00078 {
00079 ListElement *element = new ListElement(item, 0);
00080
00081 if (IsEmpty()) { // list is empty
00082 first = element;
00083 last = element;
00084 } else { // else put it after last
00085 last->next = element;
00086 last = element;
00087 }
00088 }
|
|
|
Definition at line 155 of file list.cc. References FALSE, first, NULL, and TRUE. Referenced by Append, Interrupt::CheckIfDue, Prepend, SynchList::Remove, SortedInsert, SortedRemove, and Interrupt::~Interrupt.
|
|
|
Definition at line 141 of file list.cc. References DEBUG, first, ListElement::item, ListElement::next, NULL, and VoidFunctionPtr. Referenced by Interrupt::DumpState, SynchList::Mapcar, and Scheduler::Print.
|
|
|
Definition at line 103 of file list.cc. References first, IsEmpty, last, and ListElement::next.
00104 {
00105 ListElement *element = new ListElement(item, 0);
00106
00107 if (IsEmpty()) { // list is empty
00108 first = element;
00109 last = element;
00110 } else { // else put it before first
00111 element->next = first;
00112 first = element;
00113 }
00114 }
|
|
|
Definition at line 125 of file list.cc. References NULL, and SortedRemove. Referenced by Scheduler::FindNextToRun, SynchList::Remove, Semaphore::V, Interrupt::~Interrupt, and ~List.
00126 {
00127 return SortedRemove(NULL); // Same as SortedRemove, but ignore the key
00128 }
|
|
||||||||||||
|
Definition at line 179 of file list.cc. References first, IsEmpty, ListElement::key, last, ListElement::next, and NULL. Referenced by Interrupt::CheckIfDue, and Interrupt::Schedule.
00180 {
00181 ListElement *element = new ListElement(item, sortKey);
00182 ListElement *ptr; // keep track
00183
00184 if (IsEmpty()) { // if list is empty, put
00185 first = element;
00186 last = element;
00187 } else if (sortKey < first->key) {
00188 // item goes on front of list
00189 element->next = first;
00190 first = element;
00191 } else { // look for first elt in list bigger than item
00192 for (ptr = first; ptr->next != NULL; ptr = ptr->next) {
00193 if (sortKey < ptr->next->key) {
00194 element->next = ptr->next;
00195 ptr->next = element;
00196 return;
00197 }
00198 }
00199 last->next = element; // item goes at end of list
00200 last = element;
00201 }
00202 }
|
|
|
Definition at line 218 of file list.cc. References first, IsEmpty, ListElement::item, ListElement::key, last, ListElement::next, and NULL. Referenced by Interrupt::CheckIfDue, and Remove.
00219 {
00220 ListElement *element = first;
00221 void *thing;
00222
00223 if (IsEmpty())
00224 return NULL;
00225
00226 thing = first->item;
00227 if (first == last) { // list had one item, now has none
00228 first = NULL;
00229 last = NULL;
00230 } else {
00231 first = element->next;
00232 }
00233 if (keyPtr != NULL)
00234 *keyPtr = element->key;
00235 delete element;
00236 return thing;
00237 }
|
|
|
Definition at line 62 of file list.h. Referenced by Append, IsEmpty, List, Mapcar, Prepend, SortedInsert, and SortedRemove. |
|
|
Definition at line 63 of file list.h. Referenced by Append, List, Prepend, SortedInsert, and SortedRemove. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002