XFusion API v1.3.0
|
移除 gnu 特性的双向链表. 更多...
#include "xf_predef.h"
结构体 | |
struct | xf_list_head |
双向链表结构体. 更多... | |
宏定义 | |
#define | XF_LIST_POISON1 0x00100100 |
#define | XF_LIST_POISON2 0x00200200 |
#define | XF_LIST_HEAD_INIT(name) { &(name), &(name) } |
静态定义时初始化链表。 | |
#define | XF_LIST_HEAD(name) xf_list_t name = XF_LIST_HEAD_INIT(name) |
定义一个名叫 name 的链表, 且以 name 为链表头. | |
#define | xf_list_entry(ptr, type, member) xf_container_of(ptr, type, member) |
xf_list_entry - 获取节点的结构体. | |
#define | xf_list_first_entry(ptr, type, member) xf_list_entry((ptr)->next, type, member) |
xf_list_first_entry - 获取链表中的第一个元素. | |
#define | xf_list_for_each(pos, head) for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next) |
xf_list_for_each - 迭代链表. | |
#define | __xf_list_for_each(pos, head) for ((pos) = (head)->next; (pos) != (head); (pos) = (pos)->next) |
__xf_list_for_each - 迭代链表. | |
#define | xf_list_for_each_prev(pos, head) for ((pos) = (head)->prev; (pos) != (head); (pos) = (pos)->prev) |
xf_list_for_each_prev - 反向迭代链表. | |
#define | xf_list_for_each_safe(pos, n, head) |
xf_list_for_each_safe - 迭代链表的安全版本, 防止删除链表节点时可能出现的问题. | |
#define | xf_list_for_each_prev_safe(pos, n, head) |
xf_list_for_each_prev_safe - 方向迭代链表的安全版本, 防止删除链表节点时可能出现的问题. | |
#define | xf_list_for_each_entry(pos, head, type, member) |
list_for_each_entry - 迭代给定类型的链表。 | |
#define | xf_list_for_each_entry_reverse(pos, head, type, member) |
list_for_each_entry_reverse - 倒序迭代给定类型的链表。 | |
#define | xf_list_prepare_entry(pos, head, type, member) ((pos) ? : xf_list_entry(head, type, member)) |
list_prepare_entry - 准备一个 pos 条目以在 list_for_each_entry_continue() 中使用。 | |
#define | xf_list_for_each_entry_continue(pos, head, type, member) |
list_for_each_entry_continue - 继续迭代给定类型的链表。 | |
#define | xf_list_for_each_entry_continue_reverse(pos, head, type, member) |
list_for_each_entry_continue_reverse - 从给定点倒序迭代。 | |
#define | xf_list_for_each_entry_from(pos, head, type, member) |
list_for_each_entry_from - 从当前点开始迭代给定类型的链表。 | |
#define | xf_list_for_each_entry_safe(pos, n, head, type, member) |
list_for_each_entry_safe - 安全地迭代给定类型的链表,可删除链表节点。 | |
#define | xf_list_for_each_entry_safe_continue(pos, n, head, type, member) |
list_for_each_entry_safe_continue - 安全地继续迭代链表,可删除链表节点。 | |
#define | xf_list_for_each_entry_safe_from(pos, n, head, type, member) |
list_for_each_entry_safe_from - 安全地从当前点迭代链表,可删除链表节点。 | |
#define | xf_list_for_each_entry_safe_reverse(pos, n, head, type, member) |
list_for_each_entry_safe_reverse - 安全地倒序迭代链表,可删除链表节点。 | |
#define | xf_list_safe_reset_next(pos, n, type, member) (n) = xf_list_entry((pos)->member.next, type, member) |
list_safe_reset_next - 重置过时的 list_for_each_entry_safe 循环。 | |
类型定义 | |
typedef struct xf_list_head | xf_list_t |
函数 | |
static void | xf_list_init (xf_list_t *list) |
动态初始化链表. | |
static void | __xf_list_add (xf_list_t *new_node, xf_list_t *prev, xf_list_t *next) |
在两个已知的连续节点之间插入一个 new_node 节点. | |
static void | xf_list_add (xf_list_t *new_node, xf_list_t *head) |
xf_list_add - 在指定节点之后添加一个 new_node. | |
static void | xf_list_add_tail (xf_list_t *new_node, xf_list_t *head) |
xf_list_add_tail - 在指定节点之前添加一个 new_node. | |
static void | __xf_list_del (xf_list_t *prev, xf_list_t *next) |
删除链表节点(list entry), 使前一个/后一个节点相互指向. | |
static void | __xf_list_del_entry (xf_list_t *entry) |
static void | xf_list_del (xf_list_t *entry) |
xf_list_del - 从链表中删除节点. | |
static void | xf_list_replace (xf_list_t *old, xf_list_t *new_node) |
xf_list_replace - 用 new_node 替换旧节点. | |
static void | xf_list_replace_init (xf_list_t *old, xf_list_t *new_node) |
xf_list_replace_init - 用 new_node 替换旧节点, 并重新初始化旧节点. | |
static void | xf_list_del_init (xf_list_t *entry) |
xf_list_del_init - 从链表中删除节点, 并重新初始化. | |
static void | xf_list_move (xf_list_t *list, xf_list_t *head) |
xf_list_move - 从一个链表中删除指定节点, 并添加为另一个链表的头节点。. | |
static void | xf_list_move_tail (xf_list_t *list, xf_list_t *head) |
xf_list_move_tail - 从一个链表中删除指定节点, 并添加为另一个链表的尾节点. | |
static int | xf_list_is_last (const xf_list_t *list, const xf_list_t *head) |
xf_list_is_last - 测试 list 是否是链表 head 中的最后一个节点. | |
static int | xf_list_empty (const xf_list_t *head) |
xf_list_empty - 测试链表是否为空. | |
static int | xf_list_empty_careful (const xf_list_t *head) |
xf_list_empty_careful - 测试链表是否为空且未被修改. | |
static void | xf_list_rotate_left (xf_list_t *head) |
xf_list_rotate_left - 将链表向左旋转. | |
static int | xf_list_is_singular (const xf_list_t *head) |
xf_list_is_singular - 测试链表是否只有一个节点. | |
static void | __xf_list_cut_position (xf_list_t *list, xf_list_t *head, xf_list_t *entry) |
static void | xf_list_cut_position (xf_list_t *list, xf_list_t *head, xf_list_t *entry) |
xf_list_cut_position - 将链表切成两部分. | |
static void | __xf_list_splice (const xf_list_t *list, xf_list_t *prev, xf_list_t *next) |
static void | xf_list_splice (const xf_list_t *list, xf_list_t *head) |
xf_list_splice - 连接两个链表, 这是为栈设计的. | |
static void | xf_list_splice_tail (xf_list_t *list, xf_list_t *head) |
xf_list_splice_tail - 连接两个链表, 每个链表都是一个队列 | |
static void | xf_list_splice_init (xf_list_t *list, xf_list_t *head) |
xf_list_splice_init - 连接两个链表并重新初始化空链表. | |
static void | xf_list_splice_tail_init (xf_list_t *list, xf_list_t *head) |
xf_list_splice_tail_init - 连接两个链表并重新初始化空链表. | |
移除 gnu 特性的双向链表.
Copyright (c) 2023, CorAL. All rights reserved.
简单的双链表实现. 一些内部函数("__xxx")在处理整个链表而不是单个条目时非常有用, 因为有时我们已经知道下一个/上一个条目, 直接使用它们而不是使用通用的单条目例程可以生成更好的代码。
xf_
前缀防止冲突. 优先使用类型定义而不是结构体.typeof
, 因此需要显式写出类型. 在文件 xf_list.h 中定义.