PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
list.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "order.h"
#include <pbl/kernel/compiler.h>

Data Structures

struct  ListNode
 List node, embedded in the listed structure. More...
 

Macros

#define LIST_NODE_NULL   {.next = NULL, .prev = NULL}
 Initializer of an unlinked node.
 

Typedefs

typedef bool(* ListFilterCallback) (ListNode *found_node, void *data)
 Filter for list_find() and its variants.
 
typedef bool(* ListForEachCallback) (ListNode *node, void *context)
 Callback for list_foreach().
 

Functions

void list_init (ListNode *head)
 Initialize a node as unlinked.
 
ListNode * list_insert_after (ListNode *node, ListNode *new_node)
 Insert a node after another one.
 
ListNode * list_insert_before (ListNode *node, ListNode *new_node)
 Insert a node before another one.
 
ListNode * list_pop_head (ListNode *node)
 Unlink the head of a list.
 
ListNode * list_pop_tail (ListNode *node)
 Unlink the tail of a list.
 
void list_remove (ListNode *node, ListNode **head, ListNode **tail)
 Unlink a node from its list.
 
ListNode * list_append (ListNode *node, ListNode *new_node)
 Append a node to the tail of a list.
 
ListNode * list_prepend (ListNode *node, ListNode *new_node)
 Prepend a node to the head of a list.
 
ListNode * list_get_next (ListNode *node)
 Get the next node.
 
ListNode * list_get_prev (ListNode *node)
 Get the previous node.
 
ListNode * list_get_tail (ListNode *node)
 Get the tail of a list.
 
ListNode * list_get_head (ListNode *node)
 Get the head of a list.
 
bool list_is_head (const ListNode *node)
 Check whether a node is the head of its list.
 
bool list_is_tail (const ListNode *node)
 Check whether a node is the tail of its list.
 
uint32_t list_count_to_tail_from (ListNode *node)
 Count the nodes from a node to the tail.
 
uint32_t list_count_to_head_from (ListNode *node)
 Count the nodes from a node to the head.
 
uint32_t list_count (ListNode *node)
 Count the nodes of a list.
 
ListNode * list_get_at (ListNode *node, int32_t index)
 Get the node at a distance from another one.
 
ListNode * list_sorted_add (ListNode *head, ListNode *new_node, Comparator comparator, bool ascending)
 Insert a node into a sorted list, keeping it sorted.
 
bool list_contains (const ListNode *head, const ListNode *node)
 Check whether a list contains a node.
 
ListNode * list_find (ListNode *node, ListFilterCallback filter_callback, void *data)
 Find the first matching node, from a node towards the tail.
 
ListNode * list_find_next (ListNode *node, ListFilterCallback filter_callback, bool wrap_around, void *data)
 Find the next matching node after a node.
 
ListNode * list_find_prev (ListNode *node, ListFilterCallback filter_callback, bool wrap_around, void *data)
 Find the previous matching node before a node.
 
ListNode * list_concatenate (ListNode *list_a, ListNode *list_b)
 Append a list to another one.
 
void list_foreach (ListNode *head, ListForEachCallback each_cb, void *context)
 Call a function on each node, from a node to the tail.
 
void list_debug_dump (ListNode *head)
 Log every node from a node to the tail with UTIL_LOG().