XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
bclst.h
浏览该文件的文档.
1
13#ifndef __xwos_lib_bclst_h__
14#define __xwos_lib_bclst_h__
15
16#include <xwos/standard.h>
17
30};
31
35#define xwlib_bclst_head xwlib_bclst_node
36
40#define XWLIB_BCLST_HEAD_INIT(n) (struct xwlib_bclst_head){&(n), &(n)}
41
45#define XWLIB_BCLST_NODE_INIT(n) (struct xwlib_bclst_node){&(n), &(n)}
46
54#define xwlib_bclst_entry(ptr, type, member) xwcc_derof((ptr), type, member)
55
63#define xwlib_bclst_first_entry(head, type, member) \
64 xwlib_bclst_entry((head)->next, type, member)
65
73#define xwlib_bclst_last_entry(head, type, member) \
74 xwlib_bclst_entry((head)->prev, type, member)
75
83#define xwlib_bclst_next_entry(p, type, member) \
84 xwlib_bclst_entry((p)->member.next, type, member)
85
93#define xwlib_bclst_prev_entry(p, type, member) \
94 xwlib_bclst_entry((p)->member.prev, type, member)
95
101#define xwlib_bclst_itr_next(p, head) \
102 for ((p) = (head)->next; (p) != (head); (p) = (p)->next)
103
109#define xwlib_bclst_itr_prev(p, head) \
110 for ((p) = (head)->prev; (p) != (head); (p) = (p)->prev)
111
119#define xwlib_bclst_itr_next_safe(p, n, head) \
120 for ((p) = (head)->next, (n) = (p)->next; \
121 (p) != (head); \
122 (p) = (n), (n) = (p)->next)
123
131#define xwlib_bclst_itr_prev_safe(p, n, head) \
132 for ((p) = (head)->prev, (n) = (p)->prev; \
133 (p) != (head); \
134 (p) = (n), (n) = (p)->prev)
135
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))
147
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))
159
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))
175
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))
191
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))
207
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))
223
228static __xwlib_inline
230{
231 h->next = h;
232 h->prev = h;
233}
234
239static __xwlib_inline
241{
242 n->next = n;
243 n->prev = n;
244}
245
252static __xwlib_inline
254{
255 return (h->next == h);
256}
257
265static __xwlib_inline
267{
268 return (n == h->next);
269}
270
278static __xwlib_inline
280{
281 return (n == h->prev);
282}
283
290static __xwlib_inline
292{
293 struct xwlib_bclst_node * next = h->next;
294 return ((next == (const struct xwlib_bclst_node *)h) && (next == h->prev));
295}
296
303static __xwlib_inline
305 struct xwlib_bclst_node * prev,
306 struct xwlib_bclst_node * next)
307{
308 next->prev = newn;
309 newn->next = next;
310 newn->prev = prev;
311 prev->next = newn;
312}
313
319static __xwlib_inline
321 struct xwlib_bclst_node * next)
322{
324
325}
326
332static __xwlib_inline
334 struct xwlib_bclst_node * prev)
335{
337}
338
344static __xwlib_inline
346 struct xwlib_bclst_node * newn)
347{
348 xwlib_bclst_add_between(newn, head, head->next);
349}
350
356static __xwlib_inline
358 struct xwlib_bclst_node * newn)
359{
360 xwlib_bclst_add_between(newn, head->prev, head);
361}
362
368static __xwlib_inline
370 struct xwlib_bclst_node * next)
371{
372 next->prev = prev;
373 prev->next = next;
374}
375
380static __xwlib_inline
382{
383 xwlib_bclst_del_between(node->prev, node->next);
384}
385
390static __xwlib_inline
392{
393 xwlib_bclst_del_between(node->prev, node->next);
395}
396
402static __xwlib_inline
404 struct xwlib_bclst_node * oldn)
405{
406 newn->next = oldn->next;
407 newn->next->prev = newn;
408 newn->prev = oldn->prev;
409 newn->prev->next = newn;
410}
411
417static __xwlib_inline
419 struct xwlib_bclst_node * oldn)
420{
421 xwlib_bclst_replace(newn, oldn);
423}
424
431static __xwlib_inline
433 struct xwlib_bclst_node * prev,
434 struct xwlib_bclst_node * next)
435{
436 struct xwlib_bclst_node * first = list->next;
437 struct xwlib_bclst_node * last = list->prev;
438
439 first->prev = prev;
440 prev->next = first;
441 last->next = next;
442 next->prev = last;
443}
444
450static __xwlib_inline
452 struct xwlib_bclst_head * list)
453{
454 if (!xwlib_bclst_tst_empty(list)) {
455 xwlib_bclst_splice_between(list, head, head->next);
456 }
457}
458
464static __xwlib_inline
466 struct xwlib_bclst_head * list)
467{
468 if (!xwlib_bclst_tst_empty(list)) {
469 xwlib_bclst_splice_between(list, head->prev, head);
470 }
471}
472
478static __xwlib_inline
480 struct xwlib_bclst_head * list)
481{
482 if (!xwlib_bclst_tst_empty(list)) {
483 xwlib_bclst_splice_between(list, head, head->next);
485 }
486}
487
493static __xwlib_inline
495 struct xwlib_bclst_head * list)
496{
497 if (!xwlib_bclst_tst_empty(list)) {
498 xwlib_bclst_splice_between(list, head->prev, head);
500 }
501}
502
509static __xwlib_inline
511 struct xwlib_bclst_node * prev,
512 struct xwlib_bclst_node * next)
513{
514 struct xwlib_bclst_node * first = seg;
515 struct xwlib_bclst_node * last = seg->prev;
516
517 first->prev = prev;
518 prev->next = first;
519 last->next = next;
520 next->prev = last;
521}
522
528static __xwlib_inline
530 struct xwlib_bclst_node * seg)
531{
532 xwlib_bclst_insseg_between(seg, head, head->next);
533}
534
540static __xwlib_inline
542 struct xwlib_bclst_node * seg)
543{
544 xwlib_bclst_insseg_between(seg, head->prev, head);
545}
546
551#endif /* xwos/lib/bclst.h */
static void xwlib_bclst_init_head(struct xwlib_bclst_node *h)
初始化一个链表头。
Definition bclst.h:229
static void xwlib_bclst_replace(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *oldn)
用一个新节点代替旧节点
Definition bclst.h:403
static void xwlib_bclst_splice_between(struct xwlib_bclst_node *list, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一条链表衔接到另一条链表的prev节点与next节点之间
Definition bclst.h:432
static void xwlib_bclst_add_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表尾部(链表头的前面)
Definition bclst.h:357
static void xwlib_bclst_init_node(struct xwlib_bclst_node *n)
初始化一个链表节点。
Definition bclst.h:240
static void xwlib_bclst_insseg_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *seg)
将一段链表片段(无链表头)衔接到另一条链表头之前
Definition bclst.h:541
static void xwlib_bclst_add_between(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一个新节点加入到prev与next之间
Definition bclst.h:304
static void xwlib_bclst_insseg_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *seg)
将一段链表片段(无链表头)衔接到另一条链表头之后
Definition bclst.h:529
static bool xwlib_bclst_tst_empty(const struct xwlib_bclst_node *h)
测试链表是否为空。
Definition bclst.h:253
static void xwlib_bclst_splice_tail(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之前
Definition bclst.h:465
static void xwlib_bclst_splice_tail_init(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之前,并重新初始化剩下的空链表头
Definition bclst.h:494
static void xwlib_bclst_add_front(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *next)
将一个节点加入到另一个节点的前面
Definition bclst.h:320
static void xwlib_bclst_add_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *newn)
将一个节点加入链表头部(链表头的后面)
Definition bclst.h:345
static void xwlib_bclst_insseg_between(struct xwlib_bclst_node *seg, struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
将一段链表片段(无链表头)衔接到另一条链表的prev节点与next节点之间
Definition bclst.h:510
static void xwlib_bclst_splice_head(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之后
Definition bclst.h:451
static bool xwlib_bclst_tst_last(struct xwlib_bclst_node *h, struct xwlib_bclst_node *n)
测试一个节点是否为指定链表的最后一个节点。
Definition bclst.h:279
static void xwlib_bclst_replace_init(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *oldn)
用一个新节点代替旧节点,并重新初始化旧节点
Definition bclst.h:418
static void xwlib_bclst_splice_head_init(struct xwlib_bclst_node *head, struct xwlib_bclst_node *list)
将一条链表衔接到另一条链表头之后,并重新初始化剩下的空链表头
Definition bclst.h:479
static void xwlib_bclst_del_init(struct xwlib_bclst_node *node)
删除一个节点,并重新初始化它
Definition bclst.h:391
static void xwlib_bclst_del_between(struct xwlib_bclst_node *prev, struct xwlib_bclst_node *next)
删除prev节点与next节点之间的节点
Definition bclst.h:369
static void xwlib_bclst_del(struct xwlib_bclst_node *node)
删除一个节点
Definition bclst.h:381
static void xwlib_bclst_add_behind(struct xwlib_bclst_node *newn, struct xwlib_bclst_node *prev)
将一个节点加入到另一个节点的后面
Definition bclst.h:333
#define xwlib_bclst_head
双循环链表头
Definition bclst.h:35
static bool xwlib_bclst_tst_first(struct xwlib_bclst_node *h, struct xwlib_bclst_node *n)
测试一个节点是否为指定链表的第一个节点。
Definition bclst.h:266
static bool xwlib_bclst_tst_empty_carefully(const struct xwlib_bclst_node *h)
测试链表是否为空且是否没有正在被修改
Definition bclst.h:291
#define __xwlib_inline
Definition compiler.h:203
双循环链表的节点
Definition bclst.h:27
struct xwlib_bclst_node * next
Definition bclst.h:28
struct xwlib_bclst_node * prev
Definition bclst.h:29
XWOS的标准头文件