Public feed
#377344
/** The Double-Linked List Structure for Elements**********************************************************************/typedef struct DListElem_{ void *data; //pointer to any kind of data struct DListElem_ *next; struct DListElem_ *prev;}DListElem;/** The Double-Linked List Structure***********************************************************************/typedef struct DList_{ int size; int (*match)(const void *key1,const void *key2); void (*destroy)(void *data); DListElem *head; DListElem *tail;}DList;/** The Double-Linked List Functions***********************************************************************//*function for initializing the Double Linked List Return: N/R */void DList_Init(DList *list,void (*destroy)(void *data));/*function for destroying the Double Linked List, after calling DList_Destroy you cant call any other function until you call DList_Init(); Return: N/R */void DList_Destroy(DList *list);/*function for inserting an element to the linked list right next to the element specified by *element with *data Return: 0 on succes | -1 on error */int DList_Ins_Next(DList *list,DListElem *element,const void *data);/*function for inserting an element to the linked list right before the element specified by *element with *data Return: 0 on succes | -1 on error */int DList_Ins_Prev(DList *list,DListElem *element,const void *data);/*function for removing an element from the linked list Return: 0 on succes | -1 on error */int DList_Remove(DList *list,DListElem *element, const void **data);/*function thats return the number of elements in the linked list */inline int DList_Size(DList *list);/*function that test if the linked list is full or not Return: true if the linked is is full | false if not */bool DList_IsFull(DList *list);/*function that traverse the whole list and apply a user defined func to each element */void DList_Traverse(DList *list, void (*pfun)(DListElem *element));/*************************MAKRO DEFINITIONS********************************//**************************************************************************/#define DList_Head(list) ((list)->head)#define DList_Tail(list) ((list)->tail)#define DList_IsHead(element) ((element)->prev==NULL ? 1 : 0)#define DList_IsTail(element) ((element)->next==NULL ? 1 : 0)#define DList_Data(element) ((element)->data)#define DList_Next(element) ((element)->next)#define DList_Prev(element) ((element)->prev)/*************************************************************************/#endif