Doubly linked list, linked lists that can be iterated over in both directions.
More...
|
#define | SOL_LIST_FOREACH(list, itr) for (itr = (list)->next; itr != (list); itr = itr->next) |
| Macro to iterate over a list easily. More...
|
|
#define | SOL_LIST_FOREACH_SAFE(list, itr, itr_next) for (itr = (list)->next, itr_next = itr->next; itr != (list); itr = itr_next, itr_next = itr_next->next) |
| Macro to iterate over a list with support for node deletion. More...
|
|
#define | SOL_LIST_GET_CONTAINER(list, type, member) (type *)((char *)(list) - offsetof(type, member)) |
| Helper macro to retrieve a pointer to the struct containing this list node. More...
|
|
#define | SOL_LIST_INIT(name) { &(name), &(name) } |
| Helper macro to initialize a sol_list structure. More...
|
|
Doubly linked list, linked lists that can be iterated over in both directions.
This special data type is designed to store node information in the same memory as the data.
See sol_list for more info.
#define SOL_LIST_FOREACH |
( |
|
list, |
|
|
|
itr |
|
) |
| for (itr = (list)->next; itr != (list); itr = itr->next) |
Macro to iterate over a list easily.
- Parameters
-
list | The list to iterate over |
itr | Variable pointing to the current node on each iteration |
- See Also
- SOL_LIST_FOREACH_SAFE
#define SOL_LIST_FOREACH_SAFE |
( |
|
list, |
|
|
|
itr, |
|
|
|
itr_next |
|
) |
| for (itr = (list)->next, itr_next = itr->next; itr != (list); itr = itr_next, itr_next = itr_next->next) |
Macro to iterate over a list with support for node deletion.
This version allows nodes to be removed without breaking the iteration.
- Parameters
-
list | The list to iterate over |
itr | Variable pointing to the current node on each iteration |
itr_next | Variable pointing to the next node on each iteration |
- See Also
- SOL_LIST_FOREACH
#define SOL_LIST_GET_CONTAINER |
( |
|
list, |
|
|
|
type, |
|
|
|
member |
|
) |
| (type *)((char *)(list) - offsetof(type, member)) |
Helper macro to retrieve a pointer to the struct containing this list node.
- Parameters
-
list | The list node |
type | Container type |
member | Name of the sol_list member in the container struct |
#define SOL_LIST_INIT |
( |
|
name | ) |
{ &(name), &(name) } |
Helper macro to initialize a sol_list
structure.
Example:
- Parameters
-
name | List to be initialized |
Structure to add list support to a type.
To make possible for instances of a given type to be part of a sol_list
, the type structure needs to begin with a sol_list
field. Example:
struct example_s {
int data;
}
Append an new node to the end of the list.
- Parameters
-
list | List pointer |
new_l | List node to be added |
References sol_list::next, and sol_list::prev.
static void sol_list_init |
( |
struct sol_list * |
list | ) |
|
|
inlinestatic |
static bool sol_list_is_empty |
( |
struct sol_list * |
list | ) |
|
|
inlinestatic |
Convenience function to check if the list is empty.
- Parameters
-
- Returns
true
if the list is empty, false
otherwise.
References sol_list::next.
static void sol_list_prepend |
( |
struct sol_list * |
list, |
|
|
struct sol_list * |
new_l |
|
) |
| |
|
inlinestatic |
Attach an new node to the beginning of the list.
- Parameters
-
list | List pointer |
new_l | List node to be added |
References sol_list::next, and sol_list::prev.
static void sol_list_remove |
( |
struct sol_list * |
list | ) |
|
|
inlinestatic |
Remove the node pointed by list
from the list.
- Parameters
-
list | Pointer to the node that will be removed from the list |
References sol_list::next, and sol_list::prev.
static void sol_list_steal |
( |
struct sol_list * |
list, |
|
|
struct sol_list * |
new_head |
|
) |
| |
|
inlinestatic |
Steals the list nodes from a list.
Steals the list nodes from a list by moving them to a new head and reseting the original list to empty state.
- Parameters
-
list | Original list pointer |
new_head | Pointer to the list that will hold the stolen nodes |
References sol_list::next, sol_list::prev, and sol_list_init().