00001 // DLinkList.hpp - Class interface for a Doubly-Linked list node with freelist 00002 00003 #ifndef __J2K__DataType__DList_HPP__ 00004 #define __J2K__DataType__DList_HPP__ 00005 00006 #include <j2k/Fred/Boolean.hpp> 00007 #include <j2k/Fred/StdTypes.hpp> 00008 #include <j2k/DataType/Link/DLink.hpp> 00009 #include <j2k/DataType/Link/DLink.cpp> 00010 00011 class DList { // Linked list class 00012 public: 00013 DList(); // Default Constructor 00014 virtual ~DList(); // Destructor 00015 00016 void clear(); // Remove all elements from the list 00017 void insert( Elem item ); // Insert an element at the current position 00018 void append( Elem item ); // Insert Elem at tail of list 00019 Elem remove(); // Remove and return current Elem 00020 void setFirst(); // Set curr to first position 00021 void prev(); // Move curr to previous position 00022 void next(); // Move curr to next position 00023 ULONG length(); // Return current length of list 00024 void setPos( ULONG pos ); // Set curr to specified position 00025 void setValue( Elem item ); // Set current element's value 00026 Elem getValue(); // Return current element's value 00027 00028 inline Elem currValue(); 00029 00030 BOOL isEmpty() const; // Return TRUE if list is empty 00031 BOOL isInList() const; // TRUE if current is in the list 00032 00033 long getPos(); // Get current position from the head 00034 long size(); // Get the size of the list 00035 long find( Elem val ); // Find a value from current 00036 long findID( ULONG ID ); // Find an ID value from current 00037 void display(); // Display all elements 00038 00039 inline void enqueue( Elem item ); 00040 inline Elem dequeue(); 00041 long findTimeStamp( double stamp ); // Find a timeStamp from current 00042 00043 // Private for Engineering purposes... 00044 private: 00045 DLink* head; // Pointer to the list header ptr 00046 DLink* tail; // Pointer to last element in the list 00047 DLink* curr; // Position of "current" element 00048 00049 ULONG pos; 00050 ULONG nbElements; // Actual number of items in list 00051 }; 00052 00053 #endif