forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / vpdf / system / dlist.h
blob19f42242c3b0dbdb600d27a7465008e8b3145c72
1 #ifndef __DLIST_H__
2 #define __DLIST_H__
4 /* dlist.h - linked list routines by Harry Sintonen <sintonen@iki.fi>
6 faster swapnodes() by Jamie van den Berge <entity@vapor.com>
7 mergesortlist() by Fabio Alemagna <falemagn@aros.org>
9 MinList.c and MinList.h are public domain as long name of all contributers
10 still appear in both files.
13 #include <stdio.h>
14 #include <exec/lists.h>
16 #if 0
17 struct dnode
19 struct dnode *n_succ;
20 struct dnode *n_pred;
23 struct dlist
25 struct dnode *l_head;
26 struct dnode *l_tail;
27 struct dnode *l_tailpred;
29 #endif
31 /* callback function type for callfornode()
33 typedef int (*LISTFUNCPTR) (struct MinNode *, void *);
35 /* return value for LISTFUNCPTR:
37 #define LFR_CONTINUE 0 /* continue list travelsal */
38 #define LFR_BREAK 1 /* stop list travelsal and return current node */
40 /* flags for callfornode()
42 #define CFNF_BACKWARDS (1 << 0)
44 /* callback function type for qsortlist()
46 typedef int (*COMPARFUNCPTR) (struct MinNode*, struct MinNode *);
49 #ifdef USE_QSL_ALL
51 /* use this as qsortlist() nmemb to sort all nodes from base
53 #define QSL_ALL 0xffffffff
55 #endif
58 #define LISTEMPTY(l) \
59 ((l)->mlh_TailPred == (struct MinNode *) (l))
61 #define CNEWLIST(l) \
62 {(struct MinNode *) &(l)->mlh_Tail, NULL, (struct MinNode *) &(l)->mlh_Head}
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
70 void newlist(
71 struct MinList *l);
73 void addhead(
74 struct MinList *l,
75 struct MinNode *n);
77 void addtail(
78 struct MinList *l,
79 struct MinNode *n);
81 void insert(
82 struct MinList *l,
83 struct MinNode *n,
84 struct MinNode *afterof);
86 struct MinNode *remhead(
87 struct MinList *l);
89 struct MinNode *remtail(
90 struct MinList *l);
92 void remnode(
93 struct MinNode *n);
95 struct MinNode *finMinNode(
96 struct MinList *l,
97 struct MinNode *n);
99 struct MinNode *callfornode(
100 struct MinList *l,
101 LISTFUNCPTR func,
102 void *userdata,
103 unsigned long int flags);
105 void qsortlist(
106 struct MinList *l,
107 struct MinNode *base,
108 unsigned long int nmemb,
109 COMPARFUNCPTR compar);
111 void mergesortlist(
112 struct MinList *l,
113 COMPARFUNCPTR compar);
115 #ifdef __cplusplus
116 } // extern "C"
117 #endif
119 #endif /* __DLIST_H__ */