fixed deleteForward and deleteBackward

Committer:
conantina
Date:
Wed Oct 12 15:03:24 2016 +0000
Revision:
0:294bc2018c3a
fixed deleteForward and deleteBackward

Who changed what in which revision?

UserRevisionLine numberNew contents of line
conantina 0:294bc2018c3a 1 #ifndef DOUBLELINKEDLIST_H
conantina 0:294bc2018c3a 2 #define DOUBLELINKEDLIST_H
conantina 0:294bc2018c3a 3
conantina 0:294bc2018c3a 4 typedef struct llnode_t {
conantina 0:294bc2018c3a 5 void* data;
conantina 0:294bc2018c3a 6 struct llnode_t* previous;
conantina 0:294bc2018c3a 7 struct llnode_t* next;
conantina 0:294bc2018c3a 8 } LLNode;
conantina 0:294bc2018c3a 9
conantina 0:294bc2018c3a 10 typedef struct dlinkedlist_t {
conantina 0:294bc2018c3a 11 struct llnode_t* head;
conantina 0:294bc2018c3a 12 struct llnode_t* tail;
conantina 0:294bc2018c3a 13 struct llnode_t* current;
conantina 0:294bc2018c3a 14 int size;
conantina 0:294bc2018c3a 15 } DLinkedList;
conantina 0:294bc2018c3a 16
conantina 0:294bc2018c3a 17
conantina 0:294bc2018c3a 18 /* A function pointer type for functions that take in void* and return nothing
conantina 0:294bc2018c3a 19 * Such a function may be useful for doing something to modify the data
conantina 0:294bc2018c3a 20 * The name of this type is "ddl_op"
conantina 0:294bc2018c3a 21 */
conantina 0:294bc2018c3a 22 typedef void (*dll_op)(void*);
conantina 0:294bc2018c3a 23
conantina 0:294bc2018c3a 24 /* A function pointer type for functions that take in two const void* and return an int
conantina 0:294bc2018c3a 25 * Such a function may be useful for comparing data
conantina 0:294bc2018c3a 26 * The name of this type is "ddl_comp"
conantina 0:294bc2018c3a 27 */
conantina 0:294bc2018c3a 28 typedef int (*dll_comp)(const void*, const void*);
conantina 0:294bc2018c3a 29
conantina 0:294bc2018c3a 30 /********************************************
conantina 0:294bc2018c3a 31 * Doublely Linked List library functions *
conantina 0:294bc2018c3a 32 * For more details on their functionality, *
conantina 0:294bc2018c3a 33 * see the documentation in doublelyLinkedList.c *
conantina 0:294bc2018c3a 34 ********************************************/
conantina 0:294bc2018c3a 35 LLNode* create_llnode(void* data);
conantina 0:294bc2018c3a 36 DLinkedList* create_dlinkedlist(void);
conantina 0:294bc2018c3a 37 void insertHead(DLinkedList* dLinkedList, void* data);
conantina 0:294bc2018c3a 38 void insertTail(DLinkedList* dLinkedList, void* data);
conantina 0:294bc2018c3a 39 int insertAfter(DLinkedList* dLinkedList, void* newData);
conantina 0:294bc2018c3a 40 int insertBefore(DLinkedList* dLinkedList, void* newData);
conantina 0:294bc2018c3a 41 void* deleteBackward(DLinkedList* dLinkedList, dll_op free_func);
conantina 0:294bc2018c3a 42 void* deleteForward(DLinkedList* dLinkedList, dll_op free_func);
conantina 0:294bc2018c3a 43 void traverseList(DLinkedList* dLinkedList, dll_op do_func);
conantina 0:294bc2018c3a 44 void destroyList(DLinkedList* dLinkedList, dll_op free_func);
conantina 0:294bc2018c3a 45 void* getHead(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 46 void* getTail(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 47 void* getCurrent(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 48 void* getNext(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 49 void* getPrevious(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 50 int getSize(DLinkedList* dLinkedList);
conantina 0:294bc2018c3a 51 #endif