43 int (*match)(
const void *key1,
const void *key2);
44 void (*destroy)(
void *data);
51 static void bwd_traverse(
SlistNode node,
void (*callback)(
const void *data));
59 if ((list = (
Slist)malloc(
sizeof(
struct SList_)))==NULL)
64 list->destroy = destroy;
78 if (
SLISTremnext(list, NULL, (
void **)&data) == 0 && list->destroy !=
92 newelement->data = (
void *)data;
97 list->tail = newelement;
99 newelement->next = list->head;
100 list->head = newelement;
105 if (node->next == NULL)
106 list->tail = newelement;
108 newelement->next = node->next;
109 node->next = newelement;
127 *data = list->head->data;
128 oldelement = list->head;
129 list->head = list->head->next;
136 if (node->next == NULL)
139 *data = node->next->data;
140 oldelement = node->next;
141 node->next = node->next->next;
143 if (node->next == NULL)
171 return list->head==node ? 1 : 0;
176 return list->tail==node ? 1 : 0;
194 if (list->match == NULL)
197 for (member = list->head; member != NULL; member = member->next)
199 if (list->match(data,
SLISTdata(member)))
213 if (list->match == NULL)
217 for (member = list->head; member != NULL; member = member->next)
219 if (list->match(*data, member->data))
251 list->head->next = NULL;
255 list->head = list->tail;
266 node->next->next=node;
286 if (cmp(tmp->data, maxmin->data) < 0)
293 tmpdata = curr->data;
294 curr->data = maxmin->data;
295 maxmin->data = tmpdata;
302 static void bwd_traverse(
SlistNode node,
void (*callback)(
const void *data))
307 bwd_traverse(node->next, callback);
308 callback(node->data);
316 for (curr=list->head; curr != NULL; curr=curr->next)
317 callback(curr->data);
322 bwd_traverse(curr, callback);