/* File: list1d.h Interface for a doubly linked list implementation of the list ADT in list1.h */ #ifndef list1d_h #define list1d_h /* Type Definitions */ typedef struct node_tag { char *item ; /* we use strings, but item could be anything */ struct node_tag *prev ; struct node_tag *next ; } node ; typedef struct { node header ; int count ; } *list ; /* Function Prototypes */ /* Make a new list */ list CreateList(void) ; /* Add item to the end of the list */ void Append(list L, char *item) ; /* Add item to the beginning of the list */ void Prepend(list L, char *item) ; /* Does item with key appear on the list? 0=No 1=Yes */ int IsMember(list L, char *key) ; /* Return the position in the list of the item with key or NULL if no such item. Note: this time, position is a pointer to the node that contains the key, since deletion is easier in a doubly linked list. */ node *Locate(list L, char *key); /* Remove item in given position from the list. See note regarding position in documentation for Locate(). */ void Delete(list L, node *position) ; /* Add list L2 to the end of list L1. L2 is destroyed. */ void Concatenate(list L1, list L2) ; /* Duplicate of the list. All items and nodes have newly allocated memory. */ list ListDup(list L) ; /* Print the contents of the list. */ void PrintList(list L) ; /* Free memory allocated to the list. */ void FreeList(list L) ; /* String in first item returned, or NULL if list is empty */ char *FirstItem(list L) ; /* String in last item returned, or NULL if list is empty */ char *LastItem(list L) ; /* Returns number of items in the list */ int CountList(list L) ; #endif