]> git.decadent.org.uk Git - ion3.git/blob - ioncore/llist.h
32ac441c735466c699e4b3f17515989c888396b9
[ion3.git] / ioncore / llist.h
1 /*
2  * ion/ioncore/llist.h
3  *
4  * Copyright (c) Tuomo Valkonen 2005-2007. 
5  * 
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef ION_IONCORE_LLIST_H
13 #define ION_IONCORE_LLIST_H
14
15 #include <limits.h>
16
17 #include "mplex.h"
18 #include "mplexpholder.h"
19 #include "extlconv.h"
20 #include "stacking.h"
21
22
23 DECLSTRUCT(WLListNode){
24     WLListNode *next, *prev;
25     WMPlexPHolder *phs;
26     WStacking *st;
27 };
28
29 typedef WLListNode *WLListIterTmp;
30
31
32 #define FOR_ALL_NODES_ON_LLIST(NODE, LL, TMP) \
33     FOR_ALL_ITER(llist_iter_init, llist_iter, NODE, LL, &(TMP))
34
35 #define FOR_ALL_REGIONS_ON_LLIST(NODE, LL, TMP) \
36     FOR_ALL_ITER(llist_iter_init, llist_iter_regions, NODE, LL, &(TMP))
37
38
39 extern void llist_iter_init(WLListIterTmp *tmp, WLListNode *llist);
40 extern WLListNode *llist_iter(WLListIterTmp *tmp);
41 extern WRegion *llist_iter_regions(WLListIterTmp *tmp);
42 extern WLListNode *llist_nth_node(WLListNode *list, uint n);
43 extern ExtlTab llist_to_table(WLListNode *list);
44 extern void llist_link_after(WLListNode **list, 
45                              WLListNode *after, WLListNode *node);
46 extern void llist_link_last(WLListNode **list, WLListNode *node);
47 extern WLListNode *llist_index_to_after(WLListNode *list, 
48                                         WLListNode *current,
49                                         int index);
50 extern void llist_unlink(WLListNode **list, WLListNode *node);
51
52 #define LLIST_INDEX_LAST              (-1)
53 #define LLIST_INDEX_AFTER_CURRENT     (-2)
54 #define LLIST_INDEX_AFTER_CURRENT_ACT (-3)
55
56 #endif /* ION_IONCORE_LLIST_H */