/* * In order to use one header file for both * sequence list and linked list, I used linked list style * this may cause inconvenient when inplementing sequence list */ #ifndef _LIST_H #define _LIST_H #include #include #include #define MAX 50 typedef struct seq { int * data; int length; int maxSize; } Seq; typedef Seq * sqList; typedef struct link { int elem; struct link * next; } Link; typedef Link * linkList; typedef struct list { sqList sql; linkList lin; } List; /* initialize list * exit with code EXIT_FAILURE if initialize fail, * otherwise nothing return */ void initList(List * L); /* return number of current elements * if list does not exist, return -1 */ int lengthList(List * L); /* find location of the element * if element exists, return location * else return false */ bool locateElem(List * L, int * i, int e); /* find element at given location * if location is bigger/smaller than length/0 * return false * else return location */ bool getElem(List * L, int i, int * e); /* insert element at given location * if location is bigger than length, insert at last * if location is 0 or negative, return false */ bool insertElem(List * L, int i, int e); /* if location is bigger than length, * or is smaller than 1, * return false */ bool deleteElem(List * L, int i, int * e); void printList (List * L); /* check if list exist and have no element */ bool emptyList (List * L); void deleteList(List * L); #endif