1 #include <search.h> 2 3 struct node { 4 struct node *next; 5 struct node *prev; 6 }; 7 insque(void * element,void * pred)8void insque(void *element, void *pred) 9 { 10 struct node *e = element; 11 struct node *p = pred; 12 13 if (!p) { 14 e->next = e->prev = 0; 15 return; 16 } 17 e->next = p->next; 18 e->prev = p; 19 p->next = e; 20 if (e->next) 21 e->next->prev = e; 22 } 23 remque(void * element)24void remque(void *element) 25 { 26 struct node *e = element; 27 28 if (e->next) 29 e->next->prev = e->prev; 30 if (e->prev) 31 e->prev->next = e->next; 32 } 33