This is an implementation of a chained list data storage.
More...
|
static void | Chained_List_init (struct Chained_List *list, uint64_t chunk_size, size_t payload_size) |
| Initializes a Chained_List. More...
|
|
static void | Chained_List_release (struct Chained_List *list) |
| Clears a Chained_List. More...
|
|
static void * | Chained_List_push (struct Chained_List *list, void *payload) |
| Adds an element to the list. More...
|
|
static uint64_t | Chained_List_count (struct Chained_List *list) |
| Counts the elements in the list. More...
|
|
static void | Chained_List_cond_merge (struct Chained_List *dest, struct Chained_List *source, int(*condition)(void *)) |
| Push all element of source satisfying condition in dest. More...
|
|
static void | Chained_List_walkthrough (struct Chained_List *list, void(*action)(void *)) |
| Call a function uppon each element of the chained list. More...
|
|
static void | Chained_List_walkthrough_arg (struct Chained_List *list, void(*action)(void *, void *), void *arg) |
| Call a function uppon each element of the chained list. More...
|
|
static void * | Chained_List_get_nth (struct Chained_List *list, uint64_t n) |
| Gets the nth element of the list. More...
|
|
static void * | Chained_List_get_nth_seq (struct Chained_List *cl, struct chained_list_view *view, uint64_t n) |
| Get a reference to the nth element of the chained list (optimised for sequential) More...
|
|
static void * | Chained_List_get_elem (struct Chained_List *list, int(*test_func)(void *, void *), void *value) |
| Get a pointer to the first element which matches a value. More...
|
|
This is an implementation of a chained list data storage.
The chained list (Chained_List) is composed of several fixed size chunks (chained_list). This implementation is prepend based (lists grows by the head) :
static void Chained_List_cond_merge |
( |
struct Chained_List * |
dest, |
|
|
struct Chained_List * |
source, |
|
|
int(*)(void *) |
condition |
|
) |
| |
|
inlinestatic |
Push all element of source satisfying condition in dest.
- Parameters
-
dest | pointer to destination list |
source | pointer to source list |
condition | test function (takes a source elem as param) returns 1 for mergin |
Definition at line 339 of file Chained_List.h.
static uint64_t Chained_List_count |
( |
struct Chained_List * |
list | ) |
|
|
inlinestatic |
Counts the elements in the list.
- Parameters
-
list | the list where to coune elements |
- Returns
- the number of elements in the list
Definition at line 328 of file Chained_List.h.
static void* Chained_List_get_elem |
( |
struct Chained_List * |
list, |
|
|
int(*)(void *, void *) |
test_func, |
|
|
void * |
value |
|
) |
| |
|
inlinestatic |
Get a pointer to the first element which matches a value.
- Parameters
-
list | pointer to a chained list list |
test_func | comparison function |
value | the wanted value |
- Returns
- the found element (NULL if not found or if list is empty)
Definition at line 416 of file Chained_List.h.
static void* Chained_List_get_nth |
( |
struct Chained_List * |
list, |
|
|
uint64_t |
n |
|
) |
| |
|
inlinestatic |
Gets the nth element of the list.
- Parameters
-
list | the list where to search the element |
n | the index of wanted element |
- Returns
- a pointer to the element (NULL if not found)
Definition at line 383 of file Chained_List.h.
Get a reference to the nth element of the chained list (optimised for sequential)
- Parameters
-
cl | pointer to a chained list list |
view | enhance sequential walking of the list by storing last chunk |
n | element index |
This function must be used in case the elements are get sequentially.
The chunk of the last found item is stored int view and the search starts from it, so the next call found next element much faster (especially when the list is hugh).
Definition at line 401 of file Chained_List.h.
static void Chained_List_init |
( |
struct Chained_List * |
list, |
|
|
uint64_t |
chunk_size, |
|
|
size_t |
payload_size |
|
) |
| |
|
inlinestatic |
Initializes a Chained_List.
- Parameters
-
list | the list ti initialize |
chunk_size | the wanted chunks size |
payload_size | the size of stored elements |
Definition at line 286 of file Chained_List.h.
static void* Chained_List_push |
( |
struct Chained_List * |
list, |
|
|
void * |
payload |
|
) |
| |
|
inlinestatic |
Adds an element to the list.
- Parameters
-
list | the list where to add the element |
payload | a pointer on the element to add |
- Returns
- a pointer on the pushed element
The elements are pushed. It means that they are added at the head of the list.
Definition at line 312 of file Chained_List.h.
static void Chained_List_release |
( |
struct Chained_List * |
list | ) |
|
|
inlinestatic |
static void Chained_List_walkthrough |
( |
struct Chained_List * |
list, |
|
|
void(*)(void *) |
action |
|
) |
| |
|
inlinestatic |
Call a function uppon each element of the chained list.
- Parameters
-
list | pointer to a chained list list |
action | function (takes element in param as void *) |
Definition at line 355 of file Chained_List.h.
static void Chained_List_walkthrough_arg |
( |
struct Chained_List * |
list, |
|
|
void(*)(void *, void *) |
action, |
|
|
void * |
arg |
|
) |
| |
|
inlinestatic |
Call a function uppon each element of the chained list.
- Parameters
-
list | pointer to a chained list |
action | function (takes element in param as void *) |
arg | arguments to give to action (second void*) |
Definition at line 369 of file Chained_List.h.