Linked List
Linked List implementation in C
|
Functions | |
void | list_init (list_t *list, size_t dataSize) |
void | list_free (list_t *list) |
void | list_destroy (list_t *list) |
void | list_push (list_t *list, const void *data) |
void | list_push_front (list_t *list, const void *data) |
uint8_t | list_pop (list_t *list, void *data) |
uint8_t | list_pop_front (list_t *list, void *data) |
uint8_t | list_get_by_index (list_t *list, uint8_t index, void *data) |
void | list_print (list_t *list, void(*printFn)(const void *data)) |
void | list_for_each (list_t *list, void(*eachFn)(const void *data, void *arg), void *arg) |
uint8_t | list_size (list_t *list) |
void list_destroy | ( | list_t * | list | ) |
Description:
This function is used to free the memory of the linked list elements and of the mutex.
list | Linked list to free the memory of the elements and mutex. |
Example:
void list_for_each | ( | list_t * | list, |
void(*)(const void *data, void *arg) | eachFn, | ||
void * | arg | ||
) |
Description:
This function is used to iterate over the elements of the list.
list | Linked list. |
eachFn | Pointer to the function that will be executed on each element. |
arg | Argument passed to eachFn. |
Example:
void list_free | ( | list_t * | list | ) |
Description:
This function is used to release the memory of the linked list elements.
list | Linked list to free the memory of its elements. |
Example:
uint8_t list_get_by_index | ( | list_t * | list, |
uint8_t | index, | ||
void * | data | ||
) |
Description:
This function is used to get the value of a node at a given index. It doesn't delete the node.
list | Linked list. |
index | Index of the node. |
data | Pointer to the variable to which will be copied the value of the node at the given index. |
Example:
void list_init | ( | list_t * | list, |
size_t | dataSize | ||
) |
uint8_t list_pop | ( | list_t * | list, |
void * | data | ||
) |
Description:
This function is used to get the node at the end of the list.
list | Linked list. |
data | Pointer to the variable to which will be copied the value of the node at the end of the list. |
Example:
uint8_t list_pop_front | ( | list_t * | list, |
void * | data | ||
) |
Description:
This function is used to get the node at the front of the list.
list | Linked list. |
data | Pointer to the variable to which will be copied the value of the node at the front of the list. |
Example:
void list_print | ( | list_t * | list, |
void(*)(const void *data) | printFn | ||
) |
Description:
This function is used to print the values of the list.
list | Linked list. |
printFn | Pointer to the function used to print the elements. |
Example:
void list_push | ( | list_t * | list, |
const void * | data | ||
) |
Description:
This function is used to add a node to the end of the list.
list | Linked list. |
data | Pointer to the variable which value will be inserted at the end of the list. |
Example:
void list_push_front | ( | list_t * | list, |
const void * | data | ||
) |
Description:
This function is used to add a node to the front of the list.
list | Linked list. |
data | Pointer to the variable which value will be inserted at the front of the list. |
Example: