42 int (*match)(
const void *key1,
const void *key2);
43 void (*destroy)(
void *data);
54 if ((list = (
Dlist)malloc(
sizeof(
struct DList_))) == NULL)
59 list->destroy = destroy;
73 list->destroy != NULL)
93 newnode->data = (
void *)data;
99 list->head->prev = NULL;
100 list->head->next = NULL;
101 list->tail = newnode;
105 newnode->next = node->next;
106 newnode->prev = node;
108 if (node->next == NULL)
109 list->tail = newnode;
111 node->next->prev = newnode;
113 node->next = newnode;
126 if (node == NULL &&
DLISTsize(list) != 0)
133 newnode->data = (
void *)data;
138 list->head = newnode;
139 list->head->prev = NULL;
140 list->head->next = NULL;
141 list->tail = newnode;
145 newnode->next = node;
146 newnode->prev = node->prev;
148 if (node->prev == NULL)
149 list->head = newnode;
151 node->prev->next = newnode;
153 node->prev = newnode;
164 if (node == NULL ||
DLISTsize(list) == 0)
173 list->head = node->next;
175 if (list->head == NULL)
178 node->next->prev = NULL;
182 node->prev->next = node->next;
184 if (node->next == NULL)
185 list->tail = node->prev;
187 node->next->prev = node->prev;
216 return list->head == node ? 1 : 0;
221 return list->tail == node ? 1 : 0;
244 if (list->match == NULL)
247 for (member = list->head; member != NULL; member = member->next)
249 if (list->match(data,
DLISTdata(member)))
266 if (list->match == NULL)
295 if (cmp(tmp->data, maxmin->data) < 0)
302 tmpdata = curr->data;
303 curr->data = maxmin->data;
304 maxmin->data = tmpdata;
316 for (curr=list->head; curr != NULL; curr=curr->next)
317 callback(curr->data);
320 for (curr=list->tail; curr != NULL; curr=curr->prev)
321 callback(curr->data);