Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Chained List

This is an implementation of a chained list data storage. More...

Modules

 Internals
 Not to be used directly.
 

Data Structures

struct  Chained_List
 This a structure wrapps the use of chained_list This is the main chain list structure to use. More...
 

Functions

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...
 

Detailed Description

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) :

int i=0;
Chained_List_init( &list, 10, sizeof(int) );
//list contains []
i++;
//list contains [0]
i++;
//list contains [1,0]
//list contains [2,1,0]

Function Documentation

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
destpointer to destination list
sourcepointer to source list
conditiontest function (takes a source elem as param) returns 1 for mergin

Definition at line 339 of file Chained_List.h.

Here is the call graph for this function:

static uint64_t Chained_List_count ( struct Chained_List list)
inlinestatic

Counts the elements in the list.

Parameters
listthe list where to coune elements
Returns
the number of elements in the list

Definition at line 328 of file Chained_List.h.

Here is the caller graph for this function:

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
listpointer to a chained list list
test_funccomparison function
valuethe wanted value
Returns
the found element (NULL if not found or if list is empty)

Definition at line 416 of file Chained_List.h.

Here is the call graph for this function:

static void* Chained_List_get_nth ( struct Chained_List list,
uint64_t  n 
)
inlinestatic

Gets the nth element of the list.

Parameters
listthe list where to search the element
nthe index of wanted element
Returns
a pointer to the element (NULL if not found)

Definition at line 383 of file Chained_List.h.

Here is the call graph for this function:

static void* Chained_List_get_nth_seq ( struct Chained_List cl,
struct chained_list_view view,
uint64_t  n 
)
inlinestatic

Get a reference to the nth element of the chained list (optimised for sequential)

Parameters
clpointer to a chained list list
viewenhance sequential walking of the list by storing last chunk
nelement 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.

Here is the call graph for this function:

Here is the caller graph for this function:

static void Chained_List_init ( struct Chained_List list,
uint64_t  chunk_size,
size_t  payload_size 
)
inlinestatic

Initializes a Chained_List.

Parameters
listthe list ti initialize
chunk_sizethe wanted chunks size
payload_sizethe size of stored elements

Definition at line 286 of file Chained_List.h.

Here is the caller graph for this function:

static void* Chained_List_push ( struct Chained_List list,
void *  payload 
)
inlinestatic

Adds an element to the list.

Parameters
listthe list where to add the element
payloada 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.

Here is the call graph for this function:

Here is the caller graph for this function:

static void Chained_List_release ( struct Chained_List list)
inlinestatic

Clears a Chained_List.

Parameters
listthe list to clear

Definition at line 298 of file Chained_List.h.

Here is the call graph for this function:

Here is the caller graph for this function:

static void Chained_List_walkthrough ( struct Chained_List list,
void(*)(void *)  action 
)
inlinestatic

Call a function uppon each element of the chained list.

Parameters
listpointer to a chained list list
actionfunction (takes element in param as void *)

Definition at line 355 of file Chained_List.h.

Here is the call graph for this function:

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
listpointer to a chained list
actionfunction (takes element in param as void *)
argarguments to give to action (second void*)

Definition at line 369 of file Chained_List.h.

Here is the call graph for this function: