13#ifndef __xwos_lib_bclst_h__
14#define __xwos_lib_bclst_h__
35#define xwlib_bclst_head xwlib_bclst_node
40#define XWLIB_BCLST_HEAD_INIT(n) (struct xwlib_bclst_head){&(n), &(n)}
45#define XWLIB_BCLST_NODE_INIT(n) (struct xwlib_bclst_node){&(n), &(n)}
54#define xwlib_bclst_entry(ptr, type, member) xwcc_derof((ptr), type, member)
63#define xwlib_bclst_first_entry(head, type, member) \
64 xwlib_bclst_entry((head)->next, type, member)
73#define xwlib_bclst_last_entry(head, type, member) \
74 xwlib_bclst_entry((head)->prev, type, member)
83#define xwlib_bclst_next_entry(p, type, member) \
84 xwlib_bclst_entry((p)->member.next, type, member)
93#define xwlib_bclst_prev_entry(p, type, member) \
94 xwlib_bclst_entry((p)->member.prev, type, member)
101#define xwlib_bclst_itr_next(p, head) \
102 for ((p) = (head)->next; (p) != (head); (p) = (p)->next)
109#define xwlib_bclst_itr_prev(p, head) \
110 for ((p) = (head)->prev; (p) != (head); (p) = (p)->prev)
119#define xwlib_bclst_itr_next_safe(p, n, head) \
120 for ((p) = (head)->next, (n) = (p)->next; \
122 (p) = (n), (n) = (p)->next)
131#define xwlib_bclst_itr_prev_safe(p, n, head) \
132 for ((p) = (head)->prev, (n) = (p)->prev; \
134 (p) = (n), (n) = (p)->prev)
143#define xwlib_bclst_itr_next_entry(p, head, type, member) \
144 for ((p) = xwlib_bclst_first_entry(head, type, member); \
145 &(p)->member != (head); \
146 (p) = xwlib_bclst_next_entry((p), type, member))
155#define xwlib_bclst_itr_prev_entry(p, head, type, member) \
156 for ((p) = xwlib_bclst_last_entry(head, type, member); \
157 &(p)->member != (head); \
158 (p) = xwlib_bclst_prev_entry((p), type, member))
170#define xwlib_bclst_itr_next_entry_safe(p, n, head, type, member) \
171 for ((p) = xwlib_bclst_first_entry(head, type, member), \
172 (n) = xwlib_bclst_next_entry((p), type, member); \
173 &(p)->member != (head); \
174 (p) = (n), (n) = xwlib_bclst_next_entry((n), type, member))
187#define xwlib_bclst_itr_next_entry_del(p, head, type, member) \
188 for ((p) = xwlib_bclst_first_entry(head, type, member); \
189 &(p)->member != (head); \
190 (p) = xwlib_bclst_first_entry(head, type, member))
202#define xwlib_bclst_itr_prev_entry_safe(p, n, head, type, member) \
203 for ((p) = xwlib_bclst_last_entry(head, type, member), \
204 (n) = xwlib_bclst_prev_entry((p), type, member); \
205 &(p)->member != (head); \
206 (p) = (n), (n) = xwlib_bclst_prev_entry((n), type, member))
219#define xwlib_bclst_itr_prev_entry_del(p, head, type, member) \
220 for ((p) = xwlib_bclst_last_entry(head, type, member); \
221 &(p)->member != (head); \
222 (p) = xwlib_bclst_last_entry(head, type, member))
255 return (h->next == h);
268 return (n == h->
next);
281 return (n == h->
prev);
static void xwlib_bclst_init_head(struct xwlib_bclst_node *h)
初始化一个链表头。
static void xwlib_bclst_replace(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *oldn)
用一个新节点代替旧节点
static void xwlib_bclst_splice_between(struct xwlib_bclst_node *list, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一条链表衔接到另一条链表的prev节点与next节点之间
static void xwlib_bclst_add_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表尾部(链表头的前面)
static void xwlib_bclst_init_node(struct xwlib_bclst_node *n)
初始化一个链表节点。
static void xwlib_bclst_insseg_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *seg)
将一段链表片段(无链表头)衔接到另一条链表头之前
static void xwlib_bclst_add_between(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一个新节点加入到prev与next之间
static void xwlib_bclst_insseg_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *seg)
将一段链表片段(无链表头)衔接到另一条链表头之后
static bool xwlib_bclst_tst_empty(const struct xwlib_bclst_node *h)
测试链表是否为空。
static void xwlib_bclst_splice_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之前
static void xwlib_bclst_splice_tail_init(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之前,并重新初始化剩下的空链表头
static void xwlib_bclst_add_front(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *next)
将一个节点加入到另一个节点的前面
static void xwlib_bclst_add_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表头部(链表头的后面)
static void xwlib_bclst_insseg_between(struct xwlib_bclst_node *seg, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一段链表片段(无链表头)衔接到另一条链表的prev节点与next节点之间
static void xwlib_bclst_splice_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之后
static bool xwlib_bclst_tst_last(struct xwlib_bclst_node *h, struct xwlib_bclst_node *n)
测试一个节点是否为指定链表的最后一个节点。
static void xwlib_bclst_replace_init(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *oldn)
用一个新节点代替旧节点,并重新初始化旧节点
static void xwlib_bclst_splice_head_init(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之后,并重新初始化剩下的空链表头
static void xwlib_bclst_del_init(struct xwlib_bclst_node *node)
删除一个节点,并重新初始化它
static void xwlib_bclst_del_between(struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
删除prev节点与next节点之间的节点
static void xwlib_bclst_del(struct xwlib_bclst_node *node)
删除一个节点
static void xwlib_bclst_add_behind(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *prev)
将一个节点加入到另一个节点的后面
#define xwlib_bclst_head
双循环链表头
static bool xwlib_bclst_tst_first(struct xwlib_bclst_node *h, struct xwlib_bclst_node *n)
测试一个节点是否为指定链表的第一个节点。
static bool xwlib_bclst_tst_empty_carefully(const struct xwlib_bclst_node *h)
测试链表是否为空且是否没有正在被修改
struct xwlib_bclst_node * next
struct xwlib_bclst_node * prev