31 #include <gwenhywfar/misc.h>
32 #include <gwenhywfar/debug.h>
75 if (l->firstElement==0)
78 el->prevElement=l->lastElement;
80 l->lastElement->nextElement=el;
97 while((el=l->firstElement)) {
116 el->nextElement=l->firstElement;
119 if (l->lastElement==0)
123 el->nextElement->prevElement=el;
147 el->prevElement->nextElement=el->nextElement;
151 el->nextElement->prevElement=el->prevElement;
154 if (l->firstElement==el)
155 l->firstElement=el->nextElement;
156 if (l->lastElement==el)
157 l->lastElement=el->prevElement;
171 return l->firstElement->data;
179 return l->lastElement->data;
217 return el->prevElement->data;
225 return el->nextElement->data;
232 static int GWEN_List1__compar_asc(
const void *a,
const void *b) {
236 return (se1->listPtr->sortFunction)(se1->data, se2->data, 1);
241 static int GWEN_List1__compar_desc(
const void *a,
const void *b) {
245 return (se1->listPtr->sortFunction)(se1->data, se2->data, 0);
254 oldFn=l->sortFunction;
278 sentry=l->firstElement;
283 next=sentry->nextElement;
284 sentry->prevElement=
NULL;
285 sentry->nextElement=
NULL;
293 l->firstElement=
NULL;
305 for (i=0; i<=count; i++) {
307 (*psentry)->listPtr=
NULL;
332 const GWEN_LIST1_SORT_ELEM *
const * pse1 = a, *
const * pse2 = b;
333 const GWEN_LIST1_SORT_ELEM *se1 = *pse1, *se2 = *pse2;
334 const GWEN_LIST1_SORT_CTX *ctx=se1->context;
339 return (ctx->list->sortFunction)(e1->data, e2->data, ctx->param);
348 oldFn=l->sortFunction;
365 GWEN_LIST1_SORT_CTX *ctx;
384 GWEN_LIST1_SORT_ELEM *e;
403 GWEN_LIST1_SORT_ELEM **tmpEntries;
404 GWEN_LIST1_SORT_ELEM **psentry;
408 GWEN_LIST1_SORT_CTX *sortContext;
418 tmpEntries=(GWEN_LIST1_SORT_ELEM **)malloc((count+1)*
sizeof(GWEN_LIST1_SORT_ELEM*));
422 sentry=l->firstElement;
425 GWEN_LIST1_SORT_ELEM *se;
429 next=sentry->nextElement;
430 sentry->prevElement=
NULL;
431 sentry->nextElement=
NULL;
439 l->firstElement=
NULL;
448 for (i=0; i<=count; i++) {
449 GWEN_LIST1_SORT_ELEM *se;
454 sentry->listPtr=
NULL;