]> git.decadent.org.uk Git - ion3.git/blob - ioncore/llist.h
d3807a91245b1c3c848e2aa3e60e317766ee2d2e
[ion3.git] / ioncore / llist.h
1 /*
2  * ion/ioncore/llist.h
3  *
4  * Copyright (c) Tuomo Valkonen 2005-2008. 
5  * 
6  * See the included file LICENSE for details.
7  */
8
9 #ifndef ION_IONCORE_LLIST_H
10 #define ION_IONCORE_LLIST_H
11
12 #include <limits.h>
13
14 #include "mplex.h"
15 #include "mplexpholder.h"
16 #include "extlconv.h"
17 #include "stacking.h"
18
19
20 DECLSTRUCT(WLListNode){
21     WLListNode *next, *prev;
22     WMPlexPHolder *phs;
23     WStacking *st;
24 };
25
26 typedef WLListNode *WLListIterTmp;
27
28
29 #define FOR_ALL_NODES_ON_LLIST(NODE, LL, TMP) \
30     FOR_ALL_ITER(llist_iter_init, llist_iter, NODE, LL, &(TMP))
31
32 #define FOR_ALL_REGIONS_ON_LLIST(NODE, LL, TMP) \
33     FOR_ALL_ITER(llist_iter_init, llist_iter_regions, NODE, LL, &(TMP))
34
35
36 extern void llist_iter_init(WLListIterTmp *tmp, WLListNode *llist);
37 extern WLListNode *llist_iter(WLListIterTmp *tmp);
38 extern WRegion *llist_iter_regions(WLListIterTmp *tmp);
39 extern WLListNode *llist_nth_node(WLListNode *list, uint n);
40 extern ExtlTab llist_to_table(WLListNode *list);
41 extern void llist_link_after(WLListNode **list, 
42                              WLListNode *after, WLListNode *node);
43 extern void llist_link_last(WLListNode **list, WLListNode *node);
44 extern WLListNode *llist_index_to_after(WLListNode *list, 
45                                         WLListNode *current,
46                                         int index);
47 extern void llist_unlink(WLListNode **list, WLListNode *node);
48
49 #define LLIST_INDEX_LAST              (-1)
50 #define LLIST_INDEX_AFTER_CURRENT     (-2)
51 #define LLIST_INDEX_AFTER_CURRENT_ACT (-3)
52
53 #endif /* ION_IONCORE_LLIST_H */