Singly-Linked List#
Singly-linked List module provides APIs to handle singly-linked list operations such as insert, push, pop, push back, sort and remove.
Note
The pop operation follows FIFO method.
Singly-Linked List module Usage#
Modules#
Functions#
Initialize a singly-linked list.
Add given item at beginning of the list.
Add item at the end of the list.
Remove and return the first element of the list.
Insert an item after the given item.
Join two lists together.
Remove an item from the list.
Sort list items.
Checks if the list is empty.
Function Documentation#
sl_slist_init#
void sl_slist_init (sl_slist_node_t ** head)
Initialize a singly-linked list.
N/A | head | Pointer to pointer of head element of list. |
80
of file platform/common/inc/sl_slist.h
sl_slist_push#
void sl_slist_push (sl_slist_node_t ** head, sl_slist_node_t * item)
Add given item at beginning of the list.
N/A | head | Pointer to pointer of head element of the list. |
N/A | item | Pointer to an item to add. |
89
of file platform/common/inc/sl_slist.h
sl_slist_push_back#
void sl_slist_push_back (sl_slist_node_t ** head, sl_slist_node_t * item)
Add item at the end of the list.
N/A | head | Pointer to the pointer of a head element of the list. |
N/A | item | Pointer to the item to add. |
99
of file platform/common/inc/sl_slist.h
sl_slist_pop#
sl_slist_node_t * sl_slist_pop (sl_slist_node_t ** head)
Remove and return the first element of the list.
N/A | head | Pointer to he pointer of the head element of the list. |
Returns
Pointer to item that was at top of the list.
109
of file platform/common/inc/sl_slist.h
sl_slist_insert#
void sl_slist_insert (sl_slist_node_t * item, sl_slist_node_t * pos)
Insert an item after the given item.
N/A | item | Pointer to an item to add. |
N/A | pos | Pointer to an item after which the item to add will be inserted. |
118
of file platform/common/inc/sl_slist.h
sl_slist_join#
void sl_slist_join (sl_slist_node_t ** head_list_1, sl_slist_node_t ** head_list_2)
Join two lists together.
N/A | head_list_1 | Pointer to the pointer of a head element of the list. |
N/A | head_list_2 | Pointer to the pointer of a head element of the list to be appended. After the call, this pointer will be invalidated (set to NULL). |
130
of file platform/common/inc/sl_slist.h
sl_slist_remove#
void sl_slist_remove (sl_slist_node_t ** head, sl_slist_node_t * item)
Remove an item from the list.
N/A | head | Pointer to pointer of the head element of list. |
N/A | item | Pointer to the item to remove. |
140
of file platform/common/inc/sl_slist.h
sl_slist_sort#
void sl_slist_sort (sl_slist_node_t ** head, bool(*)(sl_slist_node_t *item_l, sl_slist_node_t *item_r) cmp_fnct)
Sort list items.
N/A | head | Pointer to the pointer of the head element of the list. |
N/A | cmp_fnct | Pointer to function to use for sorting the list. item_l Pointer to left item. item_r Pointer to right item. Returns whether the two items are ordered (true) or not (false). |
153
of file platform/common/inc/sl_slist.h
sl_slist_is_empty#
static bool sl_slist_is_empty (sl_slist_node_t * head)
Checks if the list is empty.
N/A | head | Pointer to the head element of the list. |
162
of file platform/common/inc/sl_slist.h