/* * File: * list.h * Author: * Lindsey Kuper * Summary: * Structures and function prototypes for a generic circular doubly-linked * list. */ #ifndef _LIST_H_ #define _LIST_H_ typedef struct node { void *contents; struct node *prev; struct node *next; } node; typedef struct LIST { node *head; node *current; int length; } *list; /* Procedure: * getCurrentContents * Parameters: * ls, a list. * Purpose: * Get the contents of the current element of ls, if it exists. * Produces: * currentcontents, a void pointer. * Preconditions: * None. * Postconditions: * If the current element of ls does not exist, currentcontents is null. * Otherwise, current contents points to the contents of the current element * of ls. */ void *getCurrentContents(list ls); /* Procedure: * deleteCurrent * Parameters: * ls, a list. * Purpose: * Deletes the current element of ls, if it exists, and frees the memory that * was associated with it. * Produces: * success, an integer. * Preconditions: * ls exists. * Postconditions: * If the current element of ls does not exist: * success is 0 * ls is unchanged * Otherwise: * the "old" current element of ls has been removed from ls * the cursor is on the element of ls immediately following the "old" * current element, if it exists * success is nonzero */ int deleteCurrent(list ls); int advance(list ls); int addAfterCurrent(list ls, void *val); int moveCursorToFront(list ls); #endif /* _LIST_H_ */