gwenhywfar 5.10.1
Functions
list1.c File Reference
#include "list1_p.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>
Include dependency graph for list1.c:

Go to the source code of this file.

Functions

static int GWEN_List1__compar (const void *a, const void *b)
 
static GWENHYWFAR_CB int GWEN_List1__defaultSortFn (GWEN_UNUSED const void *a, GWEN_UNUSED const void *b, GWEN_UNUSED int ascending)
 
int GWEN_List1_Add (GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
 
int GWEN_List1_AddList (GWEN_LIST1 *dest, GWEN_LIST1 *l)
 
int GWEN_List1_Del (GWEN_LIST1_ELEMENT *el)
 
void GWEN_List1_free (GWEN_LIST1 *l)
 
int GWEN_List1_GetCount (const GWEN_LIST1 *l)
 
void * GWEN_List1_GetFirst (const GWEN_LIST1 *l)
 
void * GWEN_List1_GetLast (const GWEN_LIST1 *l)
 
int GWEN_List1_Insert (GWEN_LIST1 *l, GWEN_LIST1_ELEMENT *el)
 
GWEN_LIST1GWEN_List1_new (void)
 
GWEN_LIST1_SORT_FN GWEN_List1_SetSortFn (GWEN_LIST1 *l, GWEN_LIST1_SORT_FN fn)
 
void GWEN_List1_Sort (GWEN_LIST1 *l, int ascending)
 
void GWEN_List1_SortCtx_free (GWEN_LIST1_SORT_CTX *ctx)
 
GWEN_LIST1_SORT_CTX * GWEN_List1_SortCtx_new (GWEN_LIST1 *list, int param)
 
void GWEN_List1_SortElem_free (GWEN_LIST1_SORT_ELEM *e)
 
GWEN_LIST1_SORT_ELEM * GWEN_List1_SortElem_new (GWEN_LIST1_SORT_CTX *ctx, GWEN_LIST1_ELEMENT *elem)
 
void GWEN_List1Element_free (GWEN_LIST1_ELEMENT *el)
 
void * GWEN_List1Element_GetData (const GWEN_LIST1_ELEMENT *el)
 
void * GWEN_List1Element_GetNext (const GWEN_LIST1_ELEMENT *el)
 
void * GWEN_List1Element_GetPrevious (const GWEN_LIST1_ELEMENT *el)
 
GWEN_LIST1_ELEMENTGWEN_List1Element_new (void *d)
 

Function Documentation

◆ GWEN_List1__compar()

static int GWEN_List1__compar ( const void *  a,
const void *  b 
)
static

Definition at line 351 of file list1.c.

Referenced by GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1__defaultSortFn()

static GWENHYWFAR_CB int GWEN_List1__defaultSortFn ( GWEN_UNUSED const void *  a,
GWEN_UNUSED const void *  b,
GWEN_UNUSED int  ascending 
)
static

Definition at line 35 of file list1.c.

Referenced by GWEN_List1_new().

Here is the caller graph for this function:

◆ GWEN_List1_Add()

int GWEN_List1_Add ( GWEN_LIST1 l,
GWEN_LIST1_ELEMENT el 
)

Adds (appends) a list element at the end of the list. (This operation is also called "append" or "push_back" elsewhere.)

Definition at line 70 of file list1.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_List1_AddList(), and GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1_AddList()

int GWEN_List1_AddList ( GWEN_LIST1 dest,
GWEN_LIST1 l 
)

Adds (appends) the second list to the end of the first list. (This operation is also called "append" or "concatenate" elsewhere.)

Definition at line 97 of file list1.c.

References GWEN_List1_Add(), and GWEN_List1_Del().

Here is the call graph for this function:

◆ GWEN_List1_Del()

int GWEN_List1_Del ( GWEN_LIST1_ELEMENT el)

Deletes (removes) a list element from the list it used to belong to. The list element is not free'd or anything, it is only removed from the list it used to belong to. (This operation is also called "remove" or "unlink" elsewhere.)

Definition at line 141 of file list1.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_List1_AddList(), and GWEN_List1Element_free().

Here is the caller graph for this function:

◆ GWEN_List1_free()

void GWEN_List1_free ( GWEN_LIST1 l)

Free (delete) an existing list. The list elements are untouched by this function; they need to be freed beforehand.

Definition at line 53 of file list1.c.

References GWEN_FREE_OBJECT.

◆ GWEN_List1_GetCount()

int GWEN_List1_GetCount ( const GWEN_LIST1 l)

Returns the number of elements in this list. This value is cached in the list structure, so this function is a cheap function.

Definition at line 62 of file list1.c.

◆ GWEN_List1_GetFirst()

void * GWEN_List1_GetFirst ( const GWEN_LIST1 l)

Returns the data pointer of the first list element.

Definition at line 178 of file list1.c.

◆ GWEN_List1_GetLast()

void * GWEN_List1_GetLast ( const GWEN_LIST1 l)

Returns the data pointer of the last list element.

Definition at line 187 of file list1.c.

◆ GWEN_List1_Insert()

int GWEN_List1_Insert ( GWEN_LIST1 l,
GWEN_LIST1_ELEMENT el 
)

Inserts (prepends) a list element at the beginning of the list. (This operation is also called "prepend" or "push_front" elsewhere.)

Definition at line 114 of file list1.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

◆ GWEN_List1_new()

GWEN_LIST1 * GWEN_List1_new ( void  )

Allocate (create) a new empty list.

Definition at line 43 of file list1.c.

References GWEN_List1__defaultSortFn(), and GWEN_NEW_OBJECT.

Here is the call graph for this function:

◆ GWEN_List1_SetSortFn()

GWEN_LIST1_SORT_FN GWEN_List1_SetSortFn ( GWEN_LIST1 l,
GWEN_LIST1_SORT_FN  fn 
)

Definition at line 365 of file list1.c.

◆ GWEN_List1_Sort()

void GWEN_List1_Sort ( GWEN_LIST1 l,
int  ascending 
)

Definition at line 428 of file list1.c.

References GWEN_List1__compar(), GWEN_List1_Add(), GWEN_List1_SortCtx_free(), GWEN_List1_SortCtx_new(), GWEN_List1_SortElem_free(), GWEN_List1_SortElem_new(), and NULL.

Here is the call graph for this function:

◆ GWEN_List1_SortCtx_free()

void GWEN_List1_SortCtx_free ( GWEN_LIST1_SORT_CTX *  ctx)

Definition at line 398 of file list1.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1_SortCtx_new()

GWEN_LIST1_SORT_CTX * GWEN_List1_SortCtx_new ( GWEN_LIST1 list,
int  param 
)

Definition at line 386 of file list1.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1_SortElem_free()

void GWEN_List1_SortElem_free ( GWEN_LIST1_SORT_ELEM *  e)

Definition at line 419 of file list1.c.

References GWEN_FREE_OBJECT.

Referenced by GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1_SortElem_new()

GWEN_LIST1_SORT_ELEM * GWEN_List1_SortElem_new ( GWEN_LIST1_SORT_CTX *  ctx,
GWEN_LIST1_ELEMENT elem 
)

Definition at line 407 of file list1.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_List1_Sort().

Here is the caller graph for this function:

◆ GWEN_List1Element_free()

void GWEN_List1Element_free ( GWEN_LIST1_ELEMENT el)

Free (delete) a list element structure.

Definition at line 211 of file list1.c.

References GWEN_FREE_OBJECT, and GWEN_List1_Del().

Here is the call graph for this function:

◆ GWEN_List1Element_GetData()

void * GWEN_List1Element_GetData ( const GWEN_LIST1_ELEMENT el)

Returns the data pointer of the given list element structure.

Definition at line 222 of file list1.c.

◆ GWEN_List1Element_GetNext()

void * GWEN_List1Element_GetNext ( const GWEN_LIST1_ELEMENT el)

Returns the data pointer of the list element that is the next one (successor) to the given one in its list. If there is no such prepending list element, returns NULL.

Definition at line 238 of file list1.c.

◆ GWEN_List1Element_GetPrevious()

void * GWEN_List1Element_GetPrevious ( const GWEN_LIST1_ELEMENT el)

Returns the data pointer of the list element that is the previous (predecessor) to the given one in its list. If there is no such prepending list element, returns NULL.

Definition at line 229 of file list1.c.

◆ GWEN_List1Element_new()

GWEN_LIST1_ELEMENT * GWEN_List1Element_new ( void *  d)

Allocate (create) a new list element structure.

Definition at line 199 of file list1.c.

References GWEN_NEW_OBJECT.