µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
linked-list.h
Go to the documentation of this file.
1 
6 #ifndef UEL_LINKED_LIST_H
7 #define UEL_LINKED_LIST_H
8 
10 #include <stdint.h>
11 #include <stdbool.h>
13 
14 #include "uevloop/utils/closure.h"
15 
17 typedef struct uel_llist_node uel_llist_node_t;
20  void *value;
22  uel_llist_node_t *next;
23 };
24 
28 typedef struct uel_llist uel_llist_t;
29 struct uel_llist{
31  uel_llist_node_t *head;
33  uel_llist_node_t *tail;
35  uintptr_t count;
36 };
37 
42 void uel_llist_init(uel_llist_t *list);
43 
49 void uel_llist_push_head(uel_llist_t *list, uel_llist_node_t *node);
50 
56 void uel_llist_push_tail(uel_llist_t *list, uel_llist_node_t *node);
57 
63 uel_llist_node_t *uel_llist_pop_head(uel_llist_t *list);
64 
70 uel_llist_node_t *uel_llist_pop_tail(uel_llist_t *list);
71 
77 uel_llist_node_t *uel_llist_peek_head(uel_llist_t *list);
78 
84 uel_llist_node_t *uel_llist_peek_tail(uel_llist_t *list);
85 
92 bool uel_llist_remove(uel_llist_t *list, uel_llist_node_t *node);
93 
106 uel_llist_t uel_llist_remove_while(uel_llist_t *list, uel_closure_t *should_remove);
107 
123 void uel_llist_insert_at(uel_llist_t *list, uel_llist_node_t *node, uel_closure_t *should_insert);
124 
125 #endif /* UEL_LINKED_LIST_H */
uel_llist_pop_head
uel_llist_node_t * uel_llist_pop_head(uel_llist_t *list)
Pops a node from the head of the list.
uel_llist_remove
bool uel_llist_remove(uel_llist_t *list, uel_llist_node_t *node)
Removes a node from the queue.
uel_llist_push_tail
void uel_llist_push_tail(uel_llist_t *list, uel_llist_node_t *node)
Pushes a node to the tail of the list.
uel_llist_node::next
uel_llist_node_t * next
The next node in the list.
Definition: linked-list.h:22
uel_llist::tail
uel_llist_node_t * tail
A pointer to the tail of the list. Is NULL when the list is empty.
Definition: linked-list.h:33
closure.h
Defines closures, objects that bind functions to creating and calling contexts.
uel_llist_remove_while
uel_llist_t uel_llist_remove_while(uel_llist_t *list, uel_closure_t *should_remove)
Splits a list in two. The rupture point is determined by the supplied closure.
uel_llist_peek_head
uel_llist_node_t * uel_llist_peek_head(uel_llist_t *list)
Peeks the element at the head of the list.
uel_llist::head
uel_llist_node_t * head
A pointer to the head of the list. Is NULL when the list is empty.
Definition: linked-list.h:31
uel_llist_pop_tail
uel_llist_node_t * uel_llist_pop_tail(uel_llist_t *list)
Pops a node from the tail of the list.
uel_llist_insert_at
void uel_llist_insert_at(uel_llist_t *list, uel_llist_node_t *node, uel_closure_t *should_insert)
Scans a list until it finds a suitable spot to insert the provided node.
uel_llist_node::value
void * value
The value of the node, as a void pointer.
Definition: linked-list.h:20
uel_llist_init
void uel_llist_init(uel_llist_t *list)
Initialised a linked list.
uel_llist_peek_tail
uel_llist_node_t * uel_llist_peek_tail(uel_llist_t *list)
Peeks the element at the tail of the list.
uel_llist
Defines a linked list. If it is empty, head == tail == NULL. Pushing or popping from both the head or...
Definition: linked-list.h:29
uel_llist_push_head
void uel_llist_push_head(uel_llist_t *list, uel_llist_node_t *node)
Pushes a node to the head of the list.
uel_llist::count
uintptr_t count
The count of enqueued nodes.
Definition: linked-list.h:35
uel_llist_node
Defines a node of the linked list. Holds a void pointer.
Definition: linked-list.h:18