31#include <gwenhywfar/misc.h>
32#include <gwenhywfar/debug.h>
81 if (l->firstElement==0)
84 el->prevElement=l->lastElement;
86 l->lastElement->nextElement=el;
104 while ((el=l->firstElement)) {
124 el->nextElement=l->firstElement;
127 if (l->lastElement==0)
131 el->nextElement->prevElement=el;
156 el->prevElement->nextElement=el->nextElement;
160 el->nextElement->prevElement=el->prevElement;
163 if (l->firstElement==el)
164 l->firstElement=el->nextElement;
165 if (l->lastElement==el)
166 l->lastElement=el->prevElement;
181 return l->firstElement->data;
190 return l->lastElement->data;
232 return el->prevElement->data;
241 return el->nextElement->data;
248static int GWEN_List1__compar_asc(
const void *a,
const void *b)
253 return (se1->listPtr->sortFunction)(se1->data, se2->data, 1);
258static int GWEN_List1__compar_desc(
const void *a,
const void *b)
263 return (se1->listPtr->sortFunction)(se1->data, se2->data, 0);
273 oldFn=l->sortFunction;
298 sentry=l->firstElement;
303 next=sentry->nextElement;
304 sentry->prevElement=
NULL;
305 sentry->nextElement=
NULL;
313 l->firstElement=
NULL;
325 for (i=0; i<=count; i++) {
327 (*psentry)->listPtr=
NULL;
353 const GWEN_LIST1_SORT_ELEM *
const *pse1 = a, *
const * pse2 = b;
354 const GWEN_LIST1_SORT_ELEM *se1 = *pse1, *se2 = *pse2;
355 const GWEN_LIST1_SORT_CTX *ctx=se1->context;
360 return (ctx->list->sortFunction)(e1->data, e2->data, ctx->param);
370 oldFn=l->sortFunction;
388 GWEN_LIST1_SORT_CTX *ctx;
409 GWEN_LIST1_SORT_ELEM *e;
430 GWEN_LIST1_SORT_ELEM **tmpEntries;
431 GWEN_LIST1_SORT_ELEM **psentry;
435 GWEN_LIST1_SORT_CTX *sortContext;
445 tmpEntries=(GWEN_LIST1_SORT_ELEM **)malloc((count+1)*
sizeof(GWEN_LIST1_SORT_ELEM *));
449 sentry=l->firstElement;
452 GWEN_LIST1_SORT_ELEM *se;
456 next=sentry->nextElement;
457 sentry->prevElement=
NULL;
458 sentry->nextElement=
NULL;
466 l->firstElement=
NULL;
475 for (i=0; i<=count; i++) {
476 GWEN_LIST1_SORT_ELEM *se;
481 sentry->listPtr=
NULL;
#define DBG_ERROR(dbg_logger, format,...)
GWEN_LIST1 * GWEN_List1_new(void)
void * GWEN_List1Element_GetPrevious(const GWEN_LIST1_ELEMENT *el)
int GWEN_List1_Insert(GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
void * GWEN_List1_GetFirst(const GWEN_LIST1 *l)
int GWEN_List1_Add(GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
void GWEN_List1_SortCtx_free(GWEN_LIST1_SORT_CTX *ctx)
void GWEN_List1_free(GWEN_LIST1 *l)
int GWEN_List1_AddList(GWEN_LIST1 *dest, GWEN_LIST1 *l)
int GWEN_List1_GetCount(const GWEN_LIST1 *l)
int GWEN_List1_Del(GWEN_LIST1_ELEMENT *el)
void GWEN_List1_SortElem_free(GWEN_LIST1_SORT_ELEM *e)
void * GWEN_List1_GetLast(const GWEN_LIST1 *l)
GWEN_LIST1_SORT_FN GWEN_List1_SetSortFn(GWEN_LIST1 *l, GWEN_LIST1_SORT_FN fn)
GWEN_LIST1_ELEMENT * GWEN_List1Element_new(void *d)
static int GWEN_List1__compar(const void *a, const void *b)
void * GWEN_List1Element_GetNext(const GWEN_LIST1_ELEMENT *el)
static GWENHYWFAR_CB int GWEN_List1__defaultSortFn(GWEN_UNUSED const void *a, GWEN_UNUSED const void *b, GWEN_UNUSED int ascending)
void * GWEN_List1Element_GetData(const GWEN_LIST1_ELEMENT *el)
void GWEN_List1Element_free(GWEN_LIST1_ELEMENT *el)
void GWEN_List1_Sort(GWEN_LIST1 *l, int ascending)
GWEN_LIST1_SORT_CTX * GWEN_List1_SortCtx_new(GWEN_LIST1 *list, int param)
GWEN_LIST1_SORT_ELEM * GWEN_List1_SortElem_new(GWEN_LIST1_SORT_CTX *ctx, GWEN_LIST1_ELEMENT *elem)
int GWENHYWFAR_CB(* GWEN_LIST1_SORT_FN)(const void *a, const void *b, int ascending)
struct GWEN_LIST1 GWEN_LIST1
struct GWEN_LIST1_ELEMENT GWEN_LIST1_ELEMENT
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)