home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / OOFILE / Buildable, limited OOFILE / OOFILE headers / ooflist.hpp < prev    next >
Encoding:
Text File  |  1995-09-24  |  1.5 KB  |  45 lines  |  [TEXT/CWIE]

  1. // Start of Bit added by Ken
  2.  
  3. #include "oofbool.hpp"
  4.  
  5. class OOF_ListElement {
  6.    public:
  7.      OOF_ListElement(unsigned long theItem);    // initialize a list element
  8.  
  9.      OOF_ListElement *mNext;        // next element on list, 
  10.                             // NULL if this is the last
  11.      unsigned long mItem;             // item on the list
  12. };
  13.  
  14. // The following class defines a "list" -- a singly linked list of
  15. // list elements, each of which points to a single item on the list.
  16. //
  17. // By using the "Sorted" functions, the list can be kept in sorted
  18. // in increasing order by "key" in ListElement.
  19.  
  20. class OOF_List {
  21.   public:
  22.     OOF_List();            // initialize the list
  23.     ~OOF_List();            // de-allocate the list
  24.  
  25.     void prepend(unsigned long theItem);     // Put item at the beginning of the list
  26.     void append(unsigned long theItem);    // Put item at the end of the list
  27.     unsigned long remove();                  // Take item off the front of the list
  28.  
  29.     bool isEmpty() const;                            // is the list empty?
  30.     
  31.     bool member(unsigned long theItem) const;        // Is theItem in the list
  32.     
  33.     void sortedInsert(unsigned long theItem);                  // Put item into list sorted
  34.     void sortedInsertNoDups(unsigned long theItem);        // Put item into list sorted
  35.     
  36.     unsigned long count() const;                    // Return the number of items
  37.     
  38.   private:
  39.     OOF_ListElement *mFirst;      // Head of the list, NULL if list is empty    // owned - special case as linked list of owned items
  40.     OOF_ListElement *mLast;        // Last element of list
  41.     unsigned long    mCount;        // number of items
  42. };
  43.  
  44. // End of Bit added by Ken
  45.