#include <raplist.h>
Collaboration diagram for List:

Public Member Functions | |
| List () | |
| ~List () | |
| void | Prepend (void *item) |
| void | Append (void *item) |
| void * | Remove () |
| void | Mapcar (VoidFunctionPtr func) |
| int | IsEmpty () |
| int | Size () |
| void | SortedInsert (void *item, float sortKey) |
| void * | SortedRemove (float *keyPtr) |
| float | MinKey () |
| int | SetInsert (void *key, CompareFunction eq) |
| void * | SetRemove (void *key, CompareFunction eq) |
| void * | IsPresent (void *key, CompareFunction eq) |
| void | Purge (void *key, CompareFunction eq, VoidFunctionPtr destroy) |
Private Attributes | |
| ListElement * | first |
| ListElement * | last |
| int | size |
|
|
Definition at line 76 of file raplist.cc. References first, last, and size.
|
|
|
Definition at line 92 of file raplist.cc. References Remove().
00093 {
00094 while (Remove() != NULL)
00095 ; // delete all the List elements
00096 }
|
Here is the call graph for this function:

|
|
Definition at line 110 of file raplist.cc. References first, IsEmpty(), last, ListElement::next, and size.
00111 {
00112 ListElement *element = new ListElement(item, 0);
00113 if (IsEmpty())
00114 { // List is empty
00115 first = element;
00116 last = element;
00117 }
00118 else
00119 { // else put it after last
00120 last->next = element;
00121 last = element;
00122 }
00123
00124 size++;
00125 }
|
Here is the call graph for this function:

|
|
Definition at line 191 of file raplist.cc. References FALSE, first, and TRUE. Referenced by Append(), MinKey(), Prepend(), SortedInsert(), and SortedRemove().
|
|
||||||||||||
|
Definition at line 380 of file raplist.cc. References first, ListElement::item, and ListElement::next. Referenced by SetInsert(), and SetRemove().
00381 {
00382 ListElement *ptr;
00383
00384 for (ptr = first; ptr != NULL; ptr = ptr->next) // Check all items
00385 if ((*eq)(key, ptr->item))
00386 return ptr->item;
00387
00388 return NULL;
00389 }
|
|
|
Definition at line 180 of file raplist.cc. References first, ListElement::item, and ListElement::next. Referenced by RapAgent::LossDetection(), and RapAgent::LossHandler().
00181 {
00182 for (ListElement *ptr = first; ptr != NULL; ptr = ptr->next)
00183 (*func)((int)ptr->item);
00184 }
|
|
|
Definition at line 292 of file raplist.cc. References first, IsEmpty(), and ListElement::key.
|
Here is the call graph for this function:

|
|
Definition at line 139 of file raplist.cc. References first, IsEmpty(), last, ListElement::next, and size. Referenced by SetInsert().
00140 {
00141 ListElement *element = new ListElement(item, 0);
00142
00143 if (IsEmpty())
00144 { // List is empty
00145 first = element;
00146 last = element;
00147 }
00148 else
00149 { // else put it before first
00150 element->next = first;
00151 first = element;
00152 }
00153
00154 size++;
00155 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 400 of file raplist.cc. References first, ListElement::item, last, ListElement::next, and size. Referenced by RapAgent::LossDetection().
00401 {
00402 ListElement *prev, *curr, *temp;
00403 void *thing;
00404
00405 for (prev = NULL, curr = first; curr != NULL; ) // Check all items
00406 if ((*eq)(key, curr->item))
00407 {
00408 if (curr == first)
00409 first = curr->next;
00410 else
00411 prev->next = curr->next;
00412
00413 if (curr == last)
00414 last = prev;
00415
00416 thing = curr->item;
00417 temp = curr;
00418
00419 curr = curr->next;
00420
00421 (* destroy)((int) thing);
00422 delete temp;
00423 size--;
00424 }
00425 else
00426 {
00427 prev = curr;
00428 curr = curr->next;
00429 }
00430 }
|
|
|
Definition at line 165 of file raplist.cc. References SortedRemove(). Referenced by ~List().
00166 {
00167 return SortedRemove(NULL); // Same as SortedRemove, but ignore the key
00168 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 315 of file raplist.cc. References FALSE, IsPresent(), Prepend(), and TRUE. Referenced by RapAgent::SendPacket().
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 338 of file raplist.cc. References first, IsPresent(), ListElement::item, last, ListElement::next, and size. Referenced by RapAgent::RecvAck().
00339 {
00340 ListElement *prev, *curr;
00341 void *thing;
00342
00343 if (!IsPresent(key, eq))
00344 return NULL;
00345
00346 for (prev = NULL, curr = first;
00347 curr != NULL;
00348 prev = curr, curr = curr->next)
00349 if ((*eq)(key, curr->item))
00350 break;
00351
00352 assert(curr != NULL); // Since its present we'd better find it
00353
00354 if (curr == first)
00355 first = curr->next;
00356 else
00357 prev->next = curr->next;
00358
00359 if (curr == last)
00360 last = prev;
00361
00362 thing = curr->item;
00363 delete curr;
00364
00365 size--;
00366 return thing;
00367 }
|
Here is the call graph for this function:

|
|
Definition at line 92 of file raplist.h. References size. Referenced by RapAgent::LossDetection().
00092 {return size;} // Return the number of elements
|
|
||||||||||||
|
Definition at line 214 of file raplist.cc. References first, IsEmpty(), ListElement::key, last, ListElement::next, and size.
00215 {
00216 ListElement *element = new ListElement(item, sortKey);
00217 ListElement *ptr; // keep track
00218
00219 if (IsEmpty())
00220 { // List is empty, put in front
00221 first = element;
00222 last = element;
00223 }
00224 else if (sortKey < first->key)
00225 { // item goes on front of List
00226 element->next = first;
00227 first = element;
00228 }
00229 else
00230 { // look for first elt in List bigger than item
00231 for (ptr = first; ptr->next != NULL; ptr = ptr->next) {
00232 if (sortKey < ptr->next->key)
00233 {
00234 element->next = ptr->next;
00235 ptr->next = element;
00236 return;
00237 }
00238 }
00239 last->next = element; // item goes at end of List
00240 last = element;
00241 }
00242
00243 size++;
00244 }
|
Here is the call graph for this function:

|
|
Definition at line 259 of file raplist.cc. References first, IsEmpty(), ListElement::item, ListElement::key, last, ListElement::next, and size. Referenced by Remove().
00260 {
00261 ListElement *element = first;
00262 void *thing;
00263
00264 if (IsEmpty())
00265 return NULL;
00266
00267 thing = first->item;
00268 if (first == last)
00269 { // List had one item, now has none
00270 first = NULL;
00271 last = NULL;
00272 }
00273 else
00274 first = element->next;
00275
00276 if (keyPtr != NULL)
00277 *keyPtr = element->key;
00278 delete element;
00279
00280 size--;
00281 return thing;
00282 }
|
Here is the call graph for this function:

|
|
Definition at line 106 of file raplist.h. Referenced by Append(), IsEmpty(), IsPresent(), List(), Mapcar(), MinKey(), Prepend(), Purge(), SetRemove(), SortedInsert(), and SortedRemove(). |
|
|
Definition at line 107 of file raplist.h. Referenced by Append(), List(), Prepend(), Purge(), SetRemove(), SortedInsert(), and SortedRemove(). |
|
|
Definition at line 108 of file raplist.h. Referenced by Append(), List(), Prepend(), Purge(), SetRemove(), Size(), SortedInsert(), and SortedRemove(). |
1.3.3