c-icap-doc
0.1
|
Lists for storing items, and can grow unlimited.
More...
Macros | |
#define | ci_list_first(list) (list && (list)->items && (((list)->cursor = (list)->items->next) != NULL || 1) ? (list)->items->item : NULL) |
Gets the first item of the list and updates the list cursor to the next item. More... | |
#define | ci_list_next(list) (((list)->tmp = (list)->cursor) != NULL && (((list)->cursor = (list)->cursor->next) != NULL || 1) ? (list)->tmp->item : NULL) |
Return the next item of the list and updates the list cursor to the next item. More... | |
#define | ci_list_head(list) (list && list->items != NULL ? list->items->item : NULL) |
Return the head of the list | |
#define | ci_list_tail(list) (list && list->last != NULL ? list->last->item : NULL) |
Return last item of the list. | |
Typedefs | |
typedef struct ci_list | ci_list_t |
The ci_list_t objects can store a list of objects, with a predefined size. More... | |
Functions | |
ci_list_t * | ci_list_create (size_t init_size, size_t obj_size) |
Allocate the required memory and initialize a ci_list_t object More... | |
void | ci_list_destroy (ci_list_t *list) |
Destroy an ci_list_t object More... | |
void | ci_list_iterate (ci_list_t *list, void *data, int(*fn)(void *data, const void *obj)) |
Run the given function for each list item More... | |
const void * | ci_list_push (ci_list_t *list, const void *obj) |
Add an item to the head of list. More... | |
const void * | ci_list_push_back (ci_list_t *list, const void *data) |
Add an item to the tail of list. More... | |
void * | ci_list_pop (ci_list_t *list, void *obj) |
Remove the first item of the list. More... | |
void * | ci_list_pop_back (ci_list_t *list, void *obj) |
Remove the last item of the list. More... | |
int | ci_list_remove (ci_list_t *list, const void *obj) |
Remove the first found item equal to the obj. More... | |
const void * | ci_list_search (ci_list_t *list, const void *data) |
Return the first found item equal to the obj. More... | |
const void * | ci_list_search2 (ci_list_t *list, const void *data, int(*cmp_func)(const void *obj, const void *user_data, size_t user_data_size)) |
Return the first found item equal to the obj, using the cmp_func as comparison function. More... | |
void | ci_list_sort (ci_list_t *list) |
Sorts the list using as compare function the default. More... | |
void | ci_list_sort2 (ci_list_t *list, int(*cmp_func)(const void *obj1, const void *obj2, size_t obj_size)) |
Sorts the list using as compare function the cmp_func. More... | |
Lists for storing items, and can grow unlimited.
#define ci_list_first | ( | list | ) | (list && (list)->items && (((list)->cursor = (list)->items->next) != NULL || 1) ? (list)->items->item : NULL) |
Gets the first item of the list and updates the list cursor to the next item.
WARNING: do not mix this macro with ci_list_iterate. Use the ci_list_head and ci_list_tail macros instead
list | a pointer to the ci_list_t object |
#define ci_list_next | ( | list | ) | (((list)->tmp = (list)->cursor) != NULL && (((list)->cursor = (list)->cursor->next) != NULL || 1) ? (list)->tmp->item : NULL) |
Return the next item of the list and updates the list cursor to the next item.
WARNING: It does not check for valid list object. WARNING: do not mix this macro with ci_list_iterate!
list | a pointer to the ci_list_t object |
The ci_list_t objects can store a list of objects, with a predefined size.
The list items can be removed. The memory RAM space of list can not be decreased before the ci_list destroyed. However the memory of removed items reused.
ci_list_t* ci_list_create | ( | size_t | init_size, |
size_t | obj_size | ||
) |
Allocate the required memory and initialize a ci_list_t object
init_size | the initial memory size to use |
obj_size | the size of stored objects. If it is 0 then stores pointers to objects. |
void ci_list_destroy | ( | ci_list_t * | list | ) |
Destroy an ci_list_t object
list | a pointer to ci_list_t object to be destroyed |
void ci_list_iterate | ( | ci_list_t * | list, |
void * | data, | ||
int(*)(void *data, const void *obj) | fn | ||
) |
Run the given function for each list item
list | a pointer to the ci_list_t object |
data | a pointer to data which will be passed to the fn function |
fn | a pointer to the function which will be run for each vector item. The iteration will stop if the fn function return non zero value. |
void* ci_list_pop | ( | ci_list_t * | list, |
void * | obj | ||
) |
Remove the first item of the list.
list | a pointer to the ci_list_t object |
obj | pointer to an object to store removed item |
void* ci_list_pop_back | ( | ci_list_t * | list, |
void * | obj | ||
) |
Remove the last item of the list.
list | a pointer to the ci_list_t object |
obj | pointer to an object to store removed item |
const void* ci_list_push | ( | ci_list_t * | list, |
const void * | obj | ||
) |
Add an item to the head of list.
list | a pointer to the ci_list_t object |
obj | pointer to the object to add in vector |
const void* ci_list_push_back | ( | ci_list_t * | list, |
const void * | data | ||
) |
Add an item to the tail of list.
list | a pointer to the ci_list_t object |
obj | pointer to the object to add in vector |
int ci_list_remove | ( | ci_list_t * | list, |
const void * | obj | ||
) |
Remove the first found item equal to the obj.
list | a pointer to the ci_list_t object |
obj | pointer to an object to remove |
const void* ci_list_search | ( | ci_list_t * | list, |
const void * | data | ||
) |
Return the first found item equal to the obj.
list | a pointer to the ci_list_t object |
obj | pointer to an object to remove |
const void* ci_list_search2 | ( | ci_list_t * | list, |
const void * | data, | ||
int(*)(const void *obj, const void *user_data, size_t user_data_size) | cmp_func | ||
) |
Return the first found item equal to the obj, using the cmp_func as comparison function.
list | a pointer to the ci_list_t object |
obj | pointer to an object to remove |
cmp_func | the comparison function to use |
void ci_list_sort | ( | ci_list_t * | list | ) |
Sorts the list using as compare function the default.
list | a pointer to the ci_list_t object |
void ci_list_sort2 | ( | ci_list_t * | list, |
int(*)(const void *obj1, const void *obj2, size_t obj_size) | cmp_func | ||
) |
Sorts the list using as compare function the cmp_func.
list | a pointer to the ci_list_t object |
cmp_func | the compare function to use |