This project entails you implementing a generic doubly-linked list ADT dllist in C with a header node as pictured below.
Figure: see image.
Here is file dllist.h:
#include < stdbool.h >
#ifndef DLLIST_H
#define DLLIST_H
typedef struct header *dllist;
dllist createList(void);
// returns a newly created empty list; must be called before
// using list routines
void destroyList(dllist dl);
// deallocates entire list (the nodes; does not free data); operation undefined if list
// hasn’t been created with createList; does nothing if dl==NULL. List is undefined
// after operation.
void clearList(dllist dl);
// deallocates list items (nodes only, not data) (if applicable) and sets list to empty,
// does nothing if dl==NULL
void *getItem(dllist,int);
// returns item at location if it exists, otherwise
// returns NULL
int addItem(dllist,void *item);
// adds item to end of list; item should be created at
// runtime with malloc (in order for it to be free’ed later).
// Returns index of new item or -1 if add was unsuccesful
int insertItem(dllist l,int i,void * item);
// inserts item into list at position i; item should be created
// at runtime with malloc (in order for it to be free’ed later).
// Returns index of new item or -1 if unsuccessful; operation is
// successful when 0 <= i <= listSize(l) (0 is the first item in
// the list)
bool removeItem(dllist,int i);
// removes node from list at position i and deallocates it (does not free the data),
// returns true if operation successful, false otherwise
bool setItem(dllist,int loc,void *);
// replaces (overwrites) item in list at position loc, returns
// true if operation is succesful, false otherwise
int listSize(dllist);
// returns current number of items in list
bool listEmpty(dllist);
// returns true if list is empty, false otherwise
#endif
You may not modify this file. You have may define your two node structures (i.e. your header and list nodes) in any way that you choose as long as you implement a header node structure pointing to both the head and tail of a doubly-linked list. Your data should be of type void * to allow data of any type to be stored in the list. Note that all memory management of the data is left to the user of the module - your code should not free up any actual data stored in your container.