23 #ifndef LELY_UTIL_DLLIST_H_ 24 #define LELY_UTIL_DLLIST_H_ 30 #ifndef LELY_UTIL_DLLIST_INLINE 31 #define LELY_UTIL_DLLIST_INLINE static inline 104 #define dlnode_foreach(first, node) dlnode_foreach_(__COUNTER__, first, node) 106 #define dlnode_foreach(first, node) dlnode_foreach_(__LINE__, first, node) 108 #define dlnode_foreach_(n, first, node) dlnode_foreach__(n, first, node) 110 #define dlnode_foreach__(n, first, node) \ 111 for (struct dlnode *node = (first), \ 112 *_dlnode_next_##n = (node) ? (node)->next : NULL; \ 113 (node); (node) = _dlnode_next_##n, \ 114 _dlnode_next_##n = (node) ? (node)->next : NULL) 224 #define dllist_foreach(list, node) dlnode_foreach (dllist_first(list), node) 237 if ((node->
next = prev->
next) != NULL)
247 if ((node->
prev = next->
prev) != NULL)
391 #endif // !LELY_UTIL_DLLIST_H_ void dllist_insert_before(struct dllist *list, struct dlnode *next, struct dlnode *node)
Inserts a node into a doubly-linked list.
#define dllist_foreach(list, node)
Iterates in order over each node in a doubly-linked list.
int dlnode_insert_after(struct dlnode *prev, struct dlnode *node)
Inserts node after prev.
int dlnode_insert_before(struct dlnode *next, struct dlnode *node)
Inserts node before next.
void dlnode_remove(struct dlnode *node)
Removes node from a doubly-list.
struct dlnode * next
A pointer to the next node in the list.
struct dlnode * dllist_last(const struct dllist *list)
Returns a pointer to the last node in a doubly-linked list.
size_t dllist_size(const struct dllist *list)
Returns the size (in number of nodes) of a doubly-linked list.
struct dlnode * dllist_pop_back(struct dllist *list)
Pops a node from the back of a doubly-linked list.
int dllist_empty(const struct dllist *list)
Returns 1 if the doubly-linked list is empty, and 0 if not.
void dllist_push_back(struct dllist *list, struct dlnode *node)
Pushes a node to the back of a doubly-linked list.
struct dlnode * last
A pointer to the last node in the list.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef.h> and defines any missing functionality.
struct dllist * dllist_append(struct dllist *dst, struct dllist *src)
Appends the doubly-linked list at src to the one at dst.
void dllist_insert_after(struct dllist *list, struct dlnode *prev, struct dlnode *node)
Inserts a node into a doubly-linked list.
A node in a doubly-linked list.
void dlnode_init(struct dlnode *node)
Initializes a node in a doubly-linked list.
void dllist_push_front(struct dllist *list, struct dlnode *node)
Pushes a node to the front of a doubly-linked list.
struct dlnode * dllist_pop_front(struct dllist *list)
Pops a node from the front of a doubly-linked list.
struct dlnode * prev
A pointer to the previous node in the list.
This header file is part of the Lely libraries; it contains the compiler feature definitions.
void dllist_init(struct dllist *list)
Initializes a doubly-linked list.
struct dlnode * dllist_first(const struct dllist *list)
Returns a pointer to the first node in a doubly-linked list.
struct dlnode * first
A pointer to the first node in the list.
void dllist_remove(struct dllist *list, struct dlnode *node)
Removes a node from a doubly-linked list.