GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Functions
gp_list.h File Reference

A linked list implementation. More...

#include <core/gp_common.h>

Go to the source code of this file.

Functions

static void gp_list_push_head (gp_list *list, gp_list_head *entry)
 Pushes into head of linked list.
 
static void gp_dlist_push_head (gp_dlist *list, gp_dlist_head *entry)
 Pushes into head of double linked list.
 
static void gp_list_push_tail (gp_list *list, gp_list_head *entry)
 Pushes into tail of linked list.
 
static void gp_dlist_push_tail (gp_dlist *list, gp_dlist_head *entry)
 Pushes into tail of double linked list.
 
static void gp_dlist_push_after (gp_dlist *list, gp_dlist_head *after, gp_dlist_head *entry)
 Pushes an entry into a double linked list after an entry.
 
static void gp_dlist_push_before (gp_dlist *list, gp_dlist_head *before, gp_dlist_head *entry)
 Pushes an entry into a double linked list before an entry.
 
static gp_list_head * gp_list_pop_head (gp_list *list)
 Pops from a head of a linked list.
 
static gp_dlist_head * gp_dlist_pop_head (gp_dlist *list)
 Pops from a head of a double linked list.
 
static gp_dlist_head * gp_dlist_pop_tail (gp_dlist *list)
 Pops from a tail of a double linked list.
 
static void gp_dlist_rem (gp_dlist *list, gp_dlist_head *entry)
 Removes a entry from a double linked list.
 
static void gp_list_sort (gp_list *list, int(*cmp)(const void *, const void *))
 Sorts a linked list given a element comparsion function.
 
static void gp_dlist_sort (gp_dlist *list, int(*cmp)(const void *, const void *))
 Sorts a double linked list given a compare function.
 

Detailed Description

A linked list implementation.

Definition in file gp_list.h.

Function Documentation

◆ gp_dlist_pop_head()

static gp_dlist_head * gp_dlist_pop_head ( gp_dlist *  list)
inlinestatic

Pops from a head of a double linked list.

The returned pointer has to be converted to a structure by gp_list_entry().

Parameters
listA double linked list.
Returns
Entry list head or NULL on empty list.

Definition at line 199 of file gp_list.h.

References gp_list_pop_head().

◆ gp_dlist_pop_tail()

static gp_dlist_head * gp_dlist_pop_tail ( gp_dlist *  list)
inlinestatic

Pops from a tail of a double linked list.

The returned pointer has to be converted to a structure by gp_list_entry().

Parameters
listA double linked list.
Returns
Entry list head or NULL on empty list.

Definition at line 219 of file gp_list.h.

◆ gp_dlist_push_after()

static void gp_dlist_push_after ( gp_dlist *  list,
gp_dlist_head *  after,
gp_dlist_head *  entry 
)
inlinestatic

Pushes an entry into a double linked list after an entry.

Parameters
listA double linked list.
afterThe entry to be pushed after.
entryAn entry to be pushed.

Definition at line 130 of file gp_list.h.

◆ gp_dlist_push_before()

static void gp_dlist_push_before ( gp_dlist *  list,
gp_dlist_head *  before,
gp_dlist_head *  entry 
)
inlinestatic

Pushes an entry into a double linked list before an entry.

Parameters
listA double linked list.
beforeThe entry to be pushed before.
entryAn entry to be pushed.

Definition at line 152 of file gp_list.h.

◆ gp_dlist_push_head()

static void gp_dlist_push_head ( gp_dlist *  list,
gp_dlist_head *  entry 
)
inlinestatic

Pushes into head of double linked list.

Parameters
listA double linked list.
entryAn entry to be pushed.

Definition at line 72 of file gp_list.h.

References gp_list_push_head().

◆ gp_dlist_push_tail()

static void gp_dlist_push_tail ( gp_dlist *  list,
gp_dlist_head *  entry 
)
inlinestatic

Pushes into tail of double linked list.

Parameters
listA double linked list.
entryAn entry to be pushed.

Definition at line 115 of file gp_list.h.

◆ gp_dlist_rem()

static void gp_dlist_rem ( gp_dlist *  list,
gp_dlist_head *  entry 
)
inlinestatic

Removes a entry from a double linked list.

The entry must be present in the list!

Parameters
listA double linked list.
entryAn entry to remove.

Definition at line 246 of file gp_list.h.

◆ gp_dlist_sort()

static void gp_dlist_sort ( gp_dlist *  list,
int(*)(const void *, const void *)  cmp 
)
inlinestatic

Sorts a double linked list given a compare function.

See gp_list_sort() for detailed description.

Parameters
listA double linked list.
cmpA compare function.

Definition at line 359 of file gp_list.h.

◆ gp_list_pop_head()

static gp_list_head * gp_list_pop_head ( gp_list *  list)
inlinestatic

Pops from a head of a linked list.

The returned pointer has to be converted to a structure by gp_list_entry().

Parameters
listA linked list.
Returns
Entry list head or NULL on empty list.

Definition at line 175 of file gp_list.h.

Referenced by gp_dlist_pop_head().

◆ gp_list_push_head()

static void gp_list_push_head ( gp_list *  list,
gp_list_head *  entry 
)
inlinestatic

Pushes into head of linked list.

Parameters
listA linked list.
entryAn entry to be pushed.

Definition at line 55 of file gp_list.h.

Referenced by gp_dlist_push_head().

◆ gp_list_push_tail()

static void gp_list_push_tail ( gp_list *  list,
gp_list_head *  entry 
)
inlinestatic

Pushes into tail of linked list.

Parameters
listA linked list.
entryAn entry to be pushed.

Definition at line 102 of file gp_list.h.

◆ gp_list_sort()

static void gp_list_sort ( gp_list *  list,
int(*)(const void *, const void *)  cmp 
)
inlinestatic

Sorts a linked list given a element comparsion function.

The compare function works the same as a in the qsort() system function, however the pointers passed are pointers to list head structure. Use gp_list_entry() macro to get the pointers to the structures instead.

Example compare function would look like:

struct foo {
int i;
gp_list_head head;
};
static int cmp(const void *a, const void *b)
{
struct foo *fa = gp_list_entry(a, struct foo, head);
struct foo *fb = gp_list_entry(b, struct foo, head);
return fa->i - fb->i;
}
Parameters
listA linked list.
cmpA compare function.

Definition at line 336 of file gp_list.h.