/* File: list1.h A simple linked list ADT. */ #ifndef list1_h #define list1_h /* Type Definitions */ typedef struct node_tag { char *item ; /* we use strings, but item could be anything */ struct node_tag *next ; } node ; typedef struct { node header ; int count ; node *last ; } *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: position is actually the pointer to the node before the item with the key. This position is suitable for use with Delete() below as long as the list has not been modified. */ 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