/* basiclist.h A list ADT for general data storage (data stored as void *). cmc, updated 10/23/08 */ #ifndef BASICLIST_H #define BASICLIST_H /* type that points to general information */ typedef void *InfoPointer; /* type that points to an entire list */ typedef struct ListTag *ListPointer; /* list constructor - MUST be used before any other list functions returns pointer to newly constructed list */ ListPointer createList(void); /* returns true if list has no items */ int emptyList(ListPointer); /* clears the list of all information, but does not destroy the information; sets current information to NULL */ void clearList(ListPointer); /* returns pointers to first, last, or current information, or returns NULL if list is empty; firstInfo and lastInfo set current information to first and last, respectively */ InfoPointer firstInfo(ListPointer); InfoPointer lastInfo(ListPointer); InfoPointer currentInfo(ListPointer); /* inserts new information first, last, or before/after current information; sets current information to the inserted information */ void insertFirst(InfoPointer, ListPointer); void insertLast(InfoPointer, ListPointer); void insertBeforeCurrent(InfoPointer, ListPointer); void insertAfterCurrent(InfoPointer, ListPointer); /* deletes the first, last, or current information; returns pointer to the deleted information, or returns NULL if list is already empty; deleting the first item sets current to the new first item, deleting the last item sets current to the new last, deleting other items sets current to item preceding the deleted one */ InfoPointer deleteFirst(ListPointer); InfoPointer deleteLast(ListPointer); InfoPointer deleteCurrent(ListPointer); /* sets current pointer to first information */ void resetCurrent(ListPointer); /* sets current pointer to next information, or does nothing if current already points to last */ void advanceCurrent(ListPointer); /* returns true if list is not empty, and current information is not last information */ int hasMoreInfo(ListPointer); /* Note: assumed meaning of "current" information is the most recently accessed information - it is changed whenever an item is accessed, as described above. */ #endif