1 /* $Id: list.c 6168 2003-01-21 06:27:32Z alexk $
11 list_new(struct list *list)
13 list->head = (struct node *)&list->tail;
14 list->tailpred = (struct node *)&list->head;
19 list_addhead(struct list *list, struct node *node)
21 node->succ = list->head;
22 node->pred = (struct node *)&list->head;
23 list->head->pred = node;
29 list_addtail(struct list *list, struct node *node)
31 node->succ = (struct node *)&list->tail;
32 node->pred = list->tailpred;
33 list->tailpred->succ = node;
34 list->tailpred = node;
39 list_remhead(struct list *list)
43 node = list->head->succ;
45 node->pred = (struct node *)&list->head;
47 list->head = node->succ;
53 list_head(struct list *list)
61 list_tail(struct list *list)
63 if (list->tailpred->pred)
64 return list->tailpred;
69 list_succ(struct node *node)
77 list_pred(struct node *node)
85 list_remove(struct node *node)
87 node->pred->succ = node->succ;
88 node->succ->pred = node->pred;
93 list_remtail(struct list *list)
97 node = list_tail(list);
104 list_isempty(struct list *list)
106 return list->tailpred == (struct node *)list;
110 list_insert(struct list *list, struct node *node, struct node *pred)
114 node->succ = pred->succ;
116 pred->succ->pred = node;
119 list_addtail(list, node);
122 list_addhead(list, node);