|
Embedded SDK
Embedded SDK
|
Generic linked list implementation (singly and doubly-linked) More...
#include <stdlib.h>#include <stdbool.h>

Go to the source code of this file.
Classes | |
| struct | flist_node_t |
| Forward list node structure (singly-linked) More... | |
| struct | list_node_t |
| Doubly-linked list node structure. More... | |
Typedefs | |
| typedef struct flist_node_t | flist_node_t |
| typedef struct list_node_t | list_node_t |
| typedef void(* | f_list_node_del) (flist_node_t *node) |
| Callback function to delete/free a node. | |
| typedef bool(* | f_list_node_cmp) (const flist_node_t *a, const flist_node_t *b) |
| Callback function to compare two nodes for sorting. | |
| typedef bool(* | f_list_node_pred) (const flist_node_t *node) |
| Callback function to test a single node (unary predicate) | |
| typedef bool(* | f_list_node_bin_pred) (const flist_node_t *a, const flist_node_t *b) |
| Callback function to test two nodes for equality (binary predicate) | |
Functions | |
| bool | flist_push_front (flist_node_t **list, flist_node_t *node) |
| Add a node at the beginning of the forward list. | |
| bool | flist_pop_front (flist_node_t **list, f_list_node_del del_func) |
| Remove and delete the first node from the forward list. | |
| bool | flist_push_back (flist_node_t **list, flist_node_t *node) |
| Add a node at the end of the forward list. | |
| bool | flist_pop_back (flist_node_t **list, f_list_node_del del_func) |
| Remove and delete the last node from the forward list. | |
| bool | flist_insert_after (flist_node_t **list, flist_node_t *ref, flist_node_t *node) |
| Insert a node after a reference node in the forward list. | |
| bool | flist_remove (flist_node_t **list, flist_node_t *node, f_list_node_del del_func) |
| Remove and delete a specific node from the forward list. | |
| size_t | flist_remove_if (flist_node_t **list, f_list_node_pred pred_func, f_list_node_del del_func) |
| Remove all nodes matching a predicate from the forward list. | |
| bool | flist_clear (flist_node_t **list, f_list_node_del del_func) |
| Remove and delete all nodes from the forward list. | |
| size_t | flist_size (flist_node_t *const *list) |
| Get the number of nodes in the forward list. | |
| bool | flist_empty (flist_node_t *const *list) |
| Check if the forward list is empty. | |
| bool | flist_sort (flist_node_t **list, f_list_node_cmp cmp_func) |
| Sort the forward list using a comparison function. | |
| size_t | flist_unique (flist_node_t **list, f_list_node_bin_pred pred_func, f_list_node_del del_func) |
| Remove consecutive duplicate nodes from the forward list. | |
| bool | flist_reverse (flist_node_t **list) |
| Reverse the order of nodes in the forward list. | |
| bool | list_push_front (list_node_t **list, list_node_t *node) |
| Add a node at the beginning of the doubly-linked list. | |
| bool | list_pop_front (list_node_t **list, f_list_node_del del_func) |
| Remove and delete the first node from the doubly-linked list. | |
| bool | list_push_back (list_node_t **list, list_node_t *node) |
| Add a node at the end of the doubly-linked list. | |
| bool | list_pop_back (list_node_t **list, f_list_node_del del_func) |
| Remove and delete the last node from the doubly-linked list. | |
| bool | list_insert_before (list_node_t **list, list_node_t *ref, list_node_t *node) |
| Insert a node before a reference node in the doubly-linked list. | |
| bool | list_insert_after (list_node_t **list, list_node_t *ref, list_node_t *node) |
| Insert a node after a reference node in the doubly-linked list. | |
| bool | list_remove (list_node_t **list, list_node_t *node, f_list_node_del del_func) |
| Remove and delete a specific node from the doubly-linked list. | |
| size_t | list_remove_if (list_node_t **list, f_list_node_pred pred_func, f_list_node_del del_func) |
| Remove all nodes matching a predicate from the doubly-linked list. | |
| bool | list_clear (list_node_t **list, f_list_node_del del_func) |
| Remove and delete all nodes from the doubly-linked list. | |
| size_t | list_size (list_node_t *const *list) |
| Get the number of nodes in the doubly-linked list. | |
| bool | list_empty (list_node_t *const *list) |
| Check if the doubly-linked list is empty. | |
| bool | list_sort (list_node_t **list, f_list_node_cmp cmp_func) |
| Sort the doubly-linked list using a comparison function. | |
| size_t | list_unique (list_node_t **list, f_list_node_bin_pred pred_func, f_list_node_del del_func) |
| Remove consecutive duplicate nodes from the doubly-linked list. | |
| bool | list_reverse (list_node_t **list) |
| Reverse the order of nodes in the doubly-linked list. | |
Generic linked list implementation (singly and doubly-linked)
This file provides both forward lists (singly-linked) and doubly-linked lists. Based on app-ethereum implementation.
Definition in file lists.h.
| f_list_node_bin_pred |
Callback function to test two nodes for equality (binary predicate)
This function is used by flist_unique() and list_unique() to determine if two consecutive nodes are considered equal and should be deduplicated.
| [in] | a | First node to compare |
| [in] | b | Second node to compare |
| f_list_node_cmp |
Callback function to compare two nodes for sorting.
This function is used by flist_sort() and list_sort() to determine node order. It should return true if node 'a' should come before node 'b' in the sorted list.
| [in] | a | First node to compare |
| [in] | b | Second node to compare |
| f_list_node_del |
Callback function to delete/free a node.
This function is called when a node needs to be deleted from the list. It should free any resources associated with the node and the node itself.
| [in] | node | The node to delete (never NULL when called by list functions) |
| f_list_node_pred |
Callback function to test a single node (unary predicate)
This function is used by flist_remove_if() and list_remove_if() to determine which nodes should be removed from the list.
| [in] | node | The node to test |
| typedef struct flist_node_t flist_node_t |
| typedef struct list_node_t list_node_t |
| bool flist_clear | ( | flist_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool flist_empty | ( | flist_node_t *const * | list | ) |
| bool flist_insert_after | ( | flist_node_t ** | list, |
| flist_node_t * | ref, | ||
| flist_node_t * | node | ||
| ) |
Insert a node after a reference node in the forward list.
| [in,out] | list | Pointer to the list head |
| [in] | ref | Reference node (must be in list) |
| [in] | node | Node to insert (must have node->next == NULL) |
| bool flist_pop_back | ( | flist_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool flist_pop_front | ( | flist_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool flist_push_back | ( | flist_node_t ** | list, |
| flist_node_t * | node | ||
| ) |
| bool flist_push_front | ( | flist_node_t ** | list, |
| flist_node_t * | node | ||
| ) |
| bool flist_remove | ( | flist_node_t ** | list, |
| flist_node_t * | node, | ||
| f_list_node_del | del_func | ||
| ) |
Remove and delete a specific node from the forward list.
| [in,out] | list | Pointer to the list head |
| [in] | node | Node to remove (must be in list) |
| [in] | del_func | Function to delete the node (can be NULL) |
| size_t flist_remove_if | ( | flist_node_t ** | list, |
| f_list_node_pred | pred_func, | ||
| f_list_node_del | del_func | ||
| ) |
Remove all nodes matching a predicate from the forward list.
| [in,out] | list | Pointer to the list head |
| [in] | pred_func | Predicate function to test each node |
| [in] | del_func | Function to delete removed nodes (can be NULL) |
| bool flist_reverse | ( | flist_node_t ** | list | ) |
| size_t flist_size | ( | flist_node_t *const * | list | ) |
| bool flist_sort | ( | flist_node_t ** | list, |
| f_list_node_cmp | cmp_func | ||
| ) |
| size_t flist_unique | ( | flist_node_t ** | list, |
| f_list_node_bin_pred | pred_func, | ||
| f_list_node_del | del_func | ||
| ) |
Remove consecutive duplicate nodes from the forward list.
| [in,out] | list | Pointer to the list head |
| [in] | pred_func | Binary predicate to test equality (returns true if a == b) |
| [in] | del_func | Function to delete removed nodes (can be NULL) |
| bool list_clear | ( | list_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool list_empty | ( | list_node_t *const * | list | ) |
| bool list_insert_after | ( | list_node_t ** | list, |
| list_node_t * | ref, | ||
| list_node_t * | node | ||
| ) |
Insert a node after a reference node in the doubly-linked list.
| [in,out] | list | Pointer to the list head |
| [in] | ref | Reference node (must be in list) |
| [in] | node | Node to insert (must have node->_list.next == NULL and node->prev == NULL) |
| bool list_insert_before | ( | list_node_t ** | list, |
| list_node_t * | ref, | ||
| list_node_t * | node | ||
| ) |
Insert a node before a reference node in the doubly-linked list.
| [in,out] | list | Pointer to the list head |
| [in] | ref | Reference node (must be in list) |
| [in] | node | Node to insert (must have node->_list.next == NULL and node->prev == NULL) |
| bool list_pop_back | ( | list_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool list_pop_front | ( | list_node_t ** | list, |
| f_list_node_del | del_func | ||
| ) |
| bool list_push_back | ( | list_node_t ** | list, |
| list_node_t * | node | ||
| ) |
| bool list_push_front | ( | list_node_t ** | list, |
| list_node_t * | node | ||
| ) |
| bool list_remove | ( | list_node_t ** | list, |
| list_node_t * | node, | ||
| f_list_node_del | del_func | ||
| ) |
Remove and delete a specific node from the doubly-linked list.
| [in,out] | list | Pointer to the list head |
| [in] | node | Node to remove (must be in list) |
| [in] | del_func | Function to delete the node (can be NULL) |
| size_t list_remove_if | ( | list_node_t ** | list, |
| f_list_node_pred | pred_func, | ||
| f_list_node_del | del_func | ||
| ) |
Remove all nodes matching a predicate from the doubly-linked list.
| [in,out] | list | Pointer to the list head |
| [in] | pred_func | Predicate function to test each node |
| [in] | del_func | Function to delete removed nodes (can be NULL) |
| bool list_reverse | ( | list_node_t ** | list | ) |
| size_t list_size | ( | list_node_t *const * | list | ) |
| bool list_sort | ( | list_node_t ** | list, |
| f_list_node_cmp | cmp_func | ||
| ) |
| size_t list_unique | ( | list_node_t ** | list, |
| f_list_node_bin_pred | pred_func, | ||
| f_list_node_del | del_func | ||
| ) |
Remove consecutive duplicate nodes from the doubly-linked list.
| [in,out] | list | Pointer to the list head |
| [in] | pred_func | Binary predicate to test equality (returns true if a == b) |
| [in] | del_func | Function to delete removed nodes (can be NULL) |