/* File: list1a.h Interface for an array implementation of the list ADT used in list1.h */ #ifndef list1a_h #define list1a_h /* Type Definitions */ /* In the array implementation, each node is just a string */ typedef char *node ; typedef struct { node *array ; int size ; int limit ; } *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) ; /* Returns the pointer to the node that contains the given key, or NULL if no such node. Note: that this is different from the representation used in the linked list implementation, but the main program doesn't need to know this. */ 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