The LevAWC Project
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
dlist.h
Go to the documentation of this file.
1 /*
2  * _____
3  * ANSI / ___/
4  * / /__
5  * \___/
6  *
7  * Filename: dlist.h
8  * Author : Kyle Loudon/Dan Levin
9  * Date : Fri Mar 22 12:40:45 GMT 2013
10  * Version : 0.51
11  * ---
12  * Description: A doubly-linked list - implemented as a pure, generic ADT.
13  *
14  * Revision history - coming up below:
15  *
16  * Date Revision message
17  * 2012-12-03 Created this file
18  * 2013-02-05 Created a new function 'int DLISTfind_remove(Dlist list, void **data)'
19  * 2013-02-19 Made some revision to the Doxygen documentation. Enhanced the description of
20  * in/out parameters - i.e. double-pointers.
21  * 2015-03-31 This code ready for ver. 0.51
22  */
23 
28 #ifndef _DLIST_H_
29 #define _DLIST_H_
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <malloc.h>
35 #include <assert.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 #define DLIST_FWD 1
46 
50 #define DLIST_BWD -1
51 
57  typedef struct DList_ *Dlist;
58 
64  typedef struct DListElmt_ *DlistNode;
65 
66  /* FUNCTION DECLARATIONS */
67 
84  Dlist DLISTinit(void (*destroy)(void *data));
85 
100  void DLISTdestroy(Dlist list);
101 
119  int DLISTinsnext(Dlist list, DlistNode node, const void *data);
120 
138  int DLISTinsprev(Dlist list, DlistNode node, const void *data);
139 
157  int DLISTremove(Dlist list, DlistNode node, void **data);
158 
166  int DLISTsize(Dlist list);
167 
174  DlistNode DLISThead(Dlist list);
175 
182  DlistNode DLISTtail(Dlist list);
183 
193  int DLISTishead(Dlist list, DlistNode node);
194 
204  int DLISTistail(Dlist list, DlistNode node);
205 
212  void *DLISTdata(DlistNode node);
213 
221  DlistNode DLISTnext(DlistNode node);
222 
230  DlistNode DLISTprev(DlistNode node);
231 
252  DlistNode DLISTfindnode(Dlist list, const void *data);
253 
267  void DLISTsetmatch(Dlist list, int (*match)(const void *key1,
268  const void *key2));
303  int DLISTfind_remove(Dlist list, void **data);
304 
321  void DLISTsort(Dlist list, int (*cmp)(const void *key1, const void *key2));
322 
336  void DLISTtraverse(Dlist list, void (*callback)(const void *data), int direction);
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif /* _DLIST_H_ */