4 * Copyright (c) Tuomo Valkonen 1999-2006.
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.
17 /*{{{ WMPlex numbered/mut.ex. list stuff */
20 void llist_iter_init(WLListIterTmp *tmp, WLListNode *llist)
26 WLListNode *llist_iter(WLListIterTmp *tmp)
35 WRegion *llist_iter_regions(WLListIterTmp *tmp)
37 WLListNode *lnode=llist_iter(tmp);
38 return (lnode==NULL ? NULL : lnode->st->reg);
42 WLListNode *llist_nth_node(WLListNode *list, uint n)
45 llist_iter_init(&tmp, list);
46 return (WLListNode*)iterable_nth(n, (VoidIterator*)llist_iter, &tmp);
50 void llist_link_after(WLListNode **list,
51 WLListNode *after, WLListNode *node)
54 LINK_ITEM_AFTER(*list, after, node, next, prev);
56 LINK_ITEM_FIRST(*list, node, next, prev);
61 void llist_link_last(WLListNode **list, WLListNode *node)
63 LINK_ITEM_LAST(*list, node, next, prev);
67 WLListNode *llist_index_to_after(WLListNode *list,
71 if(index==LLIST_INDEX_AFTER_CURRENT_ACT){
72 WLListNode *after=current;
74 WLListNode *nxt=after->next;
75 if(nxt==NULL || nxt->st==NULL || nxt->st->reg==NULL)
77 if(!region_is_activity_r(nxt->st->reg))
82 }else if(index==LLIST_INDEX_AFTER_CURRENT){
85 return (list!=NULL ? list->prev : NULL);
89 return llist_nth_node(list, index-1);
94 void llist_unlink(WLListNode **list, WLListNode *node)
96 UNLINK_ITEM(*list, node, next, prev);