|
(my)TinyLibC 0.0.1
little tiny pretty lib c
|
Go to the source code of this file.
Data Structures | |
| struct | node_t |
| struct | list_t |
| struct | node_result_t |
Macros | |
| #define | _COPY_CHECK(x) (x != 0 && (x)->copy != 0) |
| #define | _DESTROY_CHECK(x) (x != 0 && (x)->destroy != 0) |
| #define | _VOID(c, e) ((c) ? e : return_void()) |
| #define | L_LEN(x) ((x != 0) ? (x)->len : 0) |
| return the length of the list | |
| #define | L_NEXT(x) ((x != 0) ? (x)->next : 0) |
| return the next node | |
| #define | L_FIRST(list) ((list != 0) ? (list)->start : 0) |
| return the first node | |
| #define | L_LAST(list) ((list != 0) ? (list)->end : 0) |
| return the last node | |
| #define | L_COPY(x) ((_COPY_CHECK(x)) ? (x)->copy((x)->data) : 0) |
| return the copy of the node data | |
| #define | L_DATA(x) ((x != 0) ? (x)->data : 0) |
| return the data of the node | |
| #define | L_DESTROY(x) (_VOID(_DESTROY_CHECK(x), (x)->destroy(L_DATA(x)))) |
| destroy the node | |
| #define | L_DECL_FIRST(x, list) node_t *x = L_FIRST(list) |
| create a variable with the first node of the list | |
| #define | L_DECL_LAST(x, list) node_t *x = L_LAST(list) |
| create a variable with the last node of the list | |
| #define | L_EACH(x, list) L_DECL_FIRST(x, list); x != 0; x = L_NEXT(x) |
| the for each that i like | |
Functions | |
| list_t * | list_append (list_t *list, void *data, void(*destroy)(void *data), void *(*copy)(void *data)) |
append new data to list | |
| list_t * | list_create (void) |
| create an empty list | |
| node_t * | node_create (void *data, void(*destroy)(void *data), void *(*copy)(void *data)) |
| create a node | |
| void | list_delete (list_t *list) |
delete the list | |
| list_t * | list_duplicate (list_t *list) |
duplicate list | |
| node_result_t | list_find_ptrdata (list_t *list, void *data) |
find node that have a node->data == data | |
| int | list_find_ptrnode (list_t *list, node_t *node_ptr) |
find node index that have node == node_ptr | |
| node_result_t | list_find_f (list_t *list, bool(is_this_result)(void *node_data, void *param), void *param) |
find node where is_this_result(node->data, param) = 1 | |
| node_t * | list_index (list_t *list, int index) |
return node at index index | |
| list_t * | list_insert_end (list_t *list, node_t *node) |
insert node at end of list | |
| list_t * | list_insert_start (list_t *list, node_t *node) |
insert node at start of list | |
| list_t * | list_insert (list_t *list, node_t *node, int index) |
insert node at index index | |
| int | list_remove_start (list_t *list) |
remove the first node of list | |
| int | list_remove_end (list_t *list) |
remove the last node of list | |
| int | list_remove_ptrnode (list_t *list, node_t *node) |
remove node where its ptr is node | |
| int | list_remove_ptrdata (list_t *list, void *ptrdata) |
remove node where node data is ptdrdata | |
| #define _COPY_CHECK | ( | x | ) | (x != 0 && (x)->copy != 0) |
Definition at line 35 of file tlcllists.h.
| #define _DESTROY_CHECK | ( | x | ) | (x != 0 && (x)->destroy != 0) |
Definition at line 36 of file tlcllists.h.
| #define _VOID | ( | c, | |
| e | |||
| ) | ((c) ? e : return_void()) |
Definition at line 37 of file tlcllists.h.
| #define L_COPY | ( | x | ) | ((_COPY_CHECK(x)) ? (x)->copy((x)->data) : 0) |
return the copy of the node data
| x | the node |
Definition at line 73 of file tlcllists.h.
| #define L_DATA | ( | x | ) | ((x != 0) ? (x)->data : 0) |
return the data of the node
| x | the node |
Definition at line 80 of file tlcllists.h.
| #define L_DECL_FIRST | ( | x, | |
| list | |||
| ) | node_t *x = L_FIRST(list) |
create a variable with the first node of the list
| x | the variable name to create |
| list | the list |
Definition at line 95 of file tlcllists.h.
| #define L_DECL_LAST | ( | x, | |
| list | |||
| ) | node_t *x = L_LAST(list) |
create a variable with the last node of the list
| x | the variable name to create |
| list | the list |
Definition at line 102 of file tlcllists.h.
| #define L_DESTROY | ( | x | ) | (_VOID(_DESTROY_CHECK(x), (x)->destroy(L_DATA(x)))) |
destroy the node
| x | the node |
Definition at line 87 of file tlcllists.h.
| #define L_EACH | ( | x, | |
| list | |||
| ) | L_DECL_FIRST(x, list); x != 0; x = L_NEXT(x) |
the for each that i like
| x | the variable name to create |
| list | the list |
Definition at line 110 of file tlcllists.h.
| #define L_FIRST | ( | list | ) | ((list != 0) ? (list)->start : 0) |
return the first node
| list | the list |
Definition at line 59 of file tlcllists.h.
| #define L_LAST | ( | list | ) | ((list != 0) ? (list)->end : 0) |
return the last node
| list | the list |
Definition at line 66 of file tlcllists.h.
| #define L_LEN | ( | x | ) | ((x != 0) ? (x)->len : 0) |
return the length of the list
| x | the list |
Definition at line 45 of file tlcllists.h.
| #define L_NEXT | ( | x | ) | ((x != 0) ? (x)->next : 0) |
return the next node
| x | current node |
Definition at line 52 of file tlcllists.h.
| list_t * list_append | ( | list_t * | list, |
| void * | data, | ||
| void(*)(void *data) | destroy, | ||
| void *(*)(void *data) | copy | ||
| ) |
append new data to list
If destroy is NULL, the data will not be freed when the node is deleted If copy is NULL, the node will not be copied if you duplicate the list
| list | the list to update |
| data | the data to append |
| destroy | the function called when need to destroy data (can be NULL) |
| copy | the function called when need to copy data (can be NULL) |
list = 0;; the list | list_t * list_create | ( | void | ) |
create an empty list
| void list_delete | ( | list_t * | list | ) |
delete the list
| list | list to delete |
| list_t * list_duplicate | ( | list_t * | list | ) |
duplicate list
| list | the list to duplicate |
list = 0;; the new duplicated list | node_result_t list_find_f | ( | list_t * | list, |
| bool(is_this_result)(void *node_data, void *param) | , | ||
| void * | param | ||
| ) |
find node where is_this_result(node->data, param) = 1
| list | the list in which to search |
| is_this_result | function that return 1 when the item is found |
| param | additional parameter to is_this_result |
| node_result_t list_find_ptrdata | ( | list_t * | list, |
| void * | data | ||
| ) |
find node that have a node->data == data
| list | the list in which to search |
| data | the ptr to search in list |
| int list_find_ptrnode | ( | list_t * | list, |
| node_t * | node_ptr | ||
| ) |
find node index that have node == node_ptr
| list | the list in which to search |
| node_ptr | the ptr to search in list |
| node_t * list_index | ( | list_t * | list, |
| int | index | ||
| ) |
return node at index index
If the index <= 0, it return the first node If the index is out of range, it return the last node
| list | the list in which to search |
| index | the index of the node |
list = 0;; the node | list_t * list_insert | ( | list_t * | list, |
| node_t * | node, | ||
| int | index | ||
| ) |
insert node at index index
If node = 0, the node will ne be added, and list will be returned
| list | list to update |
| node | node to add |
| index | index where node will be in list |
list = 0;; list | list_t * list_insert_end | ( | list_t * | list, |
| node_t * | node | ||
| ) |
insert node at end of list
| list | list to update |
| node | node to add |
list = 0;; list | list_t * list_insert_start | ( | list_t * | list, |
| node_t * | node | ||
| ) |
insert node at start of list
| list | list to update |
| node | node to add |
list = 0;; list | int list_remove_end | ( | list_t * | list | ) |
remove the last node of list
| list | list to update |
list = 0)|(list->len = 0);; 1 | int list_remove_ptrdata | ( | list_t * | list, |
| void * | ptrdata | ||
| ) |
remove node where node data is ptdrdata
| list | list to update |
| ptrdata | ptr of data where data is in the node to remove |
| int list_remove_ptrnode | ( | list_t * | list, |
| node_t * | node | ||
| ) |
remove node where its ptr is node
| list | list to update |
| node | ptr to the node to remove |
| int list_remove_start | ( | list_t * | list | ) |
remove the first node of list
| list | list to update |
list = 0)|(list->len = 0);; 1 | node_t * node_create | ( | void * | data, |
| void(*)(void *data) | destroy, | ||
| void *(*)(void *data) | copy | ||
| ) |
create a node
If destroy is NULL, the data will not be freed when the node is deleted If copy is NULL, the node will not be copied if you duplicate the list
| data | data to set |
| destroy | function to destroy data when needed (can be NULL) |
| copy | function to copy data when needed (can be NULL) |