tac0S
Template Affectional Command Operating System
list.h
Go to the documentation of this file.
1 
15 #ifndef LIST_H
16 #define LIST_H
17 
18 #include "copyright.h"
19 #include "utility.h"
20 
28 
30 {
31  public:
32  ListElement (void *itemPtr, long long sortKey); // initialize a list element
33 
34  ListElement *next; // next element on list,
35  // NULL if this is the last
36  long long key; // priority, for a sorted list
37  void *item; // pointer to item on the list
38 };
39 
40 // The following class defines a "list" -- a singly linked list of
41 // list elements, each of which points to a single item on the list.
42 //
43 // By using the "Sorted" functions, the list can be kept in sorted
44 // in increasing order by "key" in ListElement.
45 
46 class List
47 {
48  public:
49  List (); // initialize the list
50  ~List (); // de-allocate the list
51 
52  void Prepend (void *item); // Put item at the beginning of the list
53  void Append (void *item); // Put item at the end of the list
54  void *Remove (); // Take item off the front of the list
55 
56  void Mapcar (VoidFunctionPtr func); // Apply "func" to every element
57  // on the list
58  bool IsEmpty (); // is the list empty?
59 
60 
61  // Routines to put/get items on/off list in order (sorted by key)
62  void SortedInsert (void *item, long long sortKey); // Put item into list
63  void *SortedRemove (long long *keyPtr); // Remove first item from list
64 
65  void * get(unsigned int index);
66  unsigned int size();
67 // A Tester
68  bool removeElement(void * ElementAdress);
69 
70  private:
71  ListElement * first; // Head of the list, NULL if list is empty
72  ListElement *last; // Last element of list
73 };
74 
75 #endif // LIST_H
The following class defines a "list element" – which is used to keep track of one item on a list...
Definition: list.h:29
Definition: list.h:46
ListElement(void *itemPtr, long long sortKey)
ListElement::ListElement Initialize a list element, so it can be added somewhere on a list...
Definition: list.cc:30
Miscellaneous useful definitions, including debugging routines.