31 #include <gwenhywfar/misc.h> 32 #include <gwenhywfar/debug.h> 80 if (l->firstElement==0)
83 el->prevElement=l->lastElement;
85 l->lastElement->nextElement=el;
103 while ((el=l->firstElement)) {
123 el->nextElement=l->firstElement;
126 if (l->lastElement==0)
130 el->nextElement->prevElement=el;
155 el->prevElement->nextElement=el->nextElement;
159 el->nextElement->prevElement=el->prevElement;
162 if (l->firstElement==el)
163 l->firstElement=el->nextElement;
164 if (l->lastElement==el)
165 l->lastElement=el->prevElement;
180 return l->firstElement->data;
189 return l->lastElement->data;
231 return el->prevElement->data;
240 return el->nextElement->data;
247 static int GWEN_List1__compar_asc(
const void *a,
const void *b)
252 return (se1->listPtr->sortFunction)(se1->data, se2->data, 1);
257 static int GWEN_List1__compar_desc(
const void *a,
const void *b)
262 return (se1->listPtr->sortFunction)(se1->data, se2->data, 0);
272 oldFn=l->sortFunction;
297 sentry=l->firstElement;
302 next=sentry->nextElement;
303 sentry->prevElement=
NULL;
304 sentry->nextElement=
NULL;
312 l->firstElement=
NULL;
324 for (i=0; i<=count; i++) {
326 (*psentry)->listPtr=
NULL;
352 const GWEN_LIST1_SORT_ELEM *
const *pse1 = a, *
const * pse2 = b;
353 const GWEN_LIST1_SORT_ELEM *se1 = *pse1, *se2 = *pse2;
354 const GWEN_LIST1_SORT_CTX *ctx=se1->context;
359 return (ctx->list->sortFunction)(e1->data, e2->data, ctx->param);
369 oldFn=l->sortFunction;
387 GWEN_LIST1_SORT_CTX *ctx;
408 GWEN_LIST1_SORT_ELEM *e;
429 GWEN_LIST1_SORT_ELEM **tmpEntries;
430 GWEN_LIST1_SORT_ELEM **psentry;
434 GWEN_LIST1_SORT_CTX *sortContext;
444 tmpEntries=(GWEN_LIST1_SORT_ELEM **)malloc((count+1)*
sizeof(GWEN_LIST1_SORT_ELEM *));
448 sentry=l->firstElement;
451 GWEN_LIST1_SORT_ELEM *se;
455 next=sentry->nextElement;
456 sentry->prevElement=
NULL;
457 sentry->nextElement=
NULL;
465 l->firstElement=
NULL;
474 for (i=0; i<=count; i++) {
475 GWEN_LIST1_SORT_ELEM *se;
480 sentry->listPtr=
NULL;
int GWEN_List1_Add(GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
int GWENHYWFAR_CB(* GWEN_LIST1_SORT_FN)(const void *a, const void *b, int ascending)
void * GWEN_List1_GetLast(const GWEN_LIST1 *l)
void * GWEN_List1_GetFirst(const GWEN_LIST1 *l)
#define GWEN_FREE_OBJECT(varname)
int GWEN_List1_Del(GWEN_LIST1_ELEMENT *el)
struct GWEN_LIST1 GWEN_LIST1
GWEN_LIST1 * GWEN_List1_new(void)
void GWEN_List1Element_free(GWEN_LIST1_ELEMENT *el)
GWEN_LIST1_ELEMENT * GWEN_List1Element_new(void *d)
static GWENHYWFAR_CB int GWEN_List1__defaultSortFn(const void *a, const void *b, int ascending)
#define GWEN_NEW_OBJECT(typ, varname)
GWEN_LIST1_SORT_FN GWEN_List1_SetSortFn(GWEN_LIST1 *l, GWEN_LIST1_SORT_FN fn)
void GWEN_List1_SortCtx_free(GWEN_LIST1_SORT_CTX *ctx)
int GWEN_List1_AddList(GWEN_LIST1 *dest, GWEN_LIST1 *l)
void GWEN_List1_free(GWEN_LIST1 *l)
void * GWEN_List1Element_GetPrevious(const GWEN_LIST1_ELEMENT *el)
void GWEN_List1_SortElem_free(GWEN_LIST1_SORT_ELEM *e)
struct GWEN_LIST1_ELEMENT GWEN_LIST1_ELEMENT
static int GWEN_List1__compar(const void *a, const void *b)
GWEN_LIST1_SORT_ELEM * GWEN_List1_SortElem_new(GWEN_LIST1_SORT_CTX *ctx, GWEN_LIST1_ELEMENT *elem)
#define DBG_ERROR(dbg_logger, format, args...)
void GWEN_List1_Sort(GWEN_LIST1 *l, int ascending)
int GWEN_List1_Insert(GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
void * GWEN_List1Element_GetNext(const GWEN_LIST1_ELEMENT *el)
GWEN_LIST1_SORT_CTX * GWEN_List1_SortCtx_new(GWEN_LIST1 *list, int param)
void * GWEN_List1Element_GetData(const GWEN_LIST1_ELEMENT *el)
int GWEN_List1_GetCount(const GWEN_LIST1 *l)