/* CSE 303, Spring 2009, Marty Stepp Homework 5: T9 (solution) This file specifies a provided library of lists of strings. The list is implemented as a doubly-linked list where each node has a next and prev pointer so that the list can be traversed in both directions. The list also has "dummy" head and tail nodes for ease of implementation. */ #ifndef _LINKED_LIST_H #define _LINKED_LIST_H #include // list structure types typedef struct ListNode { char* data; struct ListNode* prev; struct ListNode* next; } ListNode; typedef struct List { ListNode* front; ListNode* back; int size; bool blessed; } List; // list functions List* list_new(void); // construct new list void list_add(List* list, int index, char* word); // add at a given index void list_append(List* list, char* word); // add at end of list bool list_contains(List* list, char* word); // true if word is in list void list_free(List* list); // free list memory void list_free_deep(List* list); // free list and its strings char* list_get(List* list, int index); // return element at an index int list_index_of(List* list, char* word); // 1st index of word (or -1) void list_insert(List* list, char* word); // add at front of list bool list_is_empty(List* list); // true if list size is 0 int list_last_index_of(List* list, char* word); // last index of word (or -1) void list_print(List* list); // prints, e.g. [a, b, c] char* list_remove(List* list, int index); // remove/return from index void list_remove_element(List* list, char* word); // remove 1st occurrence void list_set(List* list, int index, char* word); // set element at index int list_size(List* list); // returns list size #endif