doc: 更新List文档

This commit is contained in:
fslongjin
2022-10-04 22:02:41 +08:00
parent bde283fc80
commit 7087e9fbc1
5 changed files with 347 additions and 1 deletions

View File

@ -60,6 +60,18 @@
  待删除的结点
### `list_del_init(struct List *entry)`
#### 描述
  从链表中删除结点entry并将这个entry使用list_init()进行重新初始化。
#### 参数
**entry**
  待删除的结点
### `bool list_empty(struct List *entry)`
#### 描述
@ -96,6 +108,334 @@
  链表中的一个结点
### `void list_replace(struct List *old, struct List *new)`
#### 描述
  将链表中的old结点替换成new结点
#### 参数
**old**
  要被换下来的结点
**new**
  要被换入链表的新的结点
(_list_entry)=
### `list_entry(ptr, type, member)`
#### 描述
  该宏能通过ptr指向的List获取到List所处的结构体的地址
#### 参数
**ptr**
  指向List结构体的指针
**type**
  要被换入链表的新的结点
**member**
  List结构体在上述的“包裹list结构体的结构体”中的变量名
### `list_first_entry(ptr, type, member)`
#### 描述
  获取链表中的第一个元素。请注意,该宏要求链表非空,否则会出错。
#### 参数
&emsp;&emsp;与{ref}`list_entry() <_list_entry>`相同
### `list_first_entry_or_null(ptr, type, member)`
#### 描述
&emsp;&emsp;获取链表中的第一个元素。若链表为空则返回NULL。
#### 参数
&emsp;&emsp;与{ref}`list_entry() <_list_entry>`相同
### `list_last_entry(ptr, type, member)`
#### 描述
&emsp;&emsp;获取链表中的最后一个元素。请注意,该宏要求链表非空,否则会出错。
#### 参数
&emsp;&emsp;与{ref}`list_entry() <_list_entry>`相同
### `list_last_entry_or_full(ptr, type, member)`
#### 描述
&emsp;&emsp;获取链表中的最后一个元素。若链表为空则返回NULL。
#### 参数
&emsp;&emsp;与{ref}`list_entry() <_list_entry>`相同
(_list_next_entry)=
### `list_next_entry(pos, member)`
#### 描述
&emsp;&emsp;获取链表中的下一个元素
#### 参数
**pos**
&emsp;&emsp;指向当前的外层结构体的指针
**member**
&emsp;&emsp;链表结构体在外层结构体内的变量名
### `list_prev_entry(pos, member)`
#### 描述
&emsp;&emsp;获取链表中的上一个元素
#### 参数
&emsp;&emsp;与{ref}`list_next_entry() <_list_next_entry>`相同
(_list_for_each)=
### `list_for_each(ptr, head)`
#### 描述
&emsp;&emsp;遍历整个链表(从前往后)
#### 参数
**ptr**
&emsp;&emsp;指向List结构体的指针
**head**
&emsp;&emsp;指向链表头结点的指针(struct List*)
### `list_for_each_prev(ptr, head)`
#### 描述
&emsp;&emsp;遍历整个链表(从后往前)
#### 参数
&emsp;&emsp;与{ref}`list_for_each() <_list_for_each>`相同
(_list_for_each_safe)=
### `list_for_each_safe(ptr, n, head)`
#### 描述
&emsp;&emsp;从前往后遍历整个链表(支持删除当前链表结点)
&emsp;&emsp;该宏通过暂存中间变量防止在迭代链表的过程中由于删除了当前ptr所指向的链表结点从而造成错误.
#### 参数
**ptr**
&emsp;&emsp;指向List结构体的指针
**n**
&emsp;&emsp;用于存储临时值的List类型的指针
**head**
&emsp;&emsp;指向链表头结点的指针(struct List*)
### `list_for_each_prev_safe(ptr, n, head)`
#### 描述
&emsp;&emsp;从后往前遍历整个链表.(支持删除当前链表结点)
&emsp;&emsp;该宏通过暂存中间变量防止在迭代链表的过程中由于删除了当前ptr所指向的链表结点从而造成错误.
#### 参数
&emsp;&emsp;与{ref}`list_for_each_safe() <_list_for_each_safe>`相同
(_list_for_each_entry)=
### `list_for_each_entry(pos, head, member)`
#### 描述
&emsp;&emsp;从头开始迭代给定类型的链表
#### 参数
**pos**
&emsp;&emsp;指向特定类型的结构体的指针
**head**
&emsp;&emsp;指向链表头结点的指针(struct List*)
**member**
&emsp;&emsp;struct List在pos的结构体中的成员变量名
### `list_for_each_entry_reverse(pos, head, member)`
#### 描述
&emsp;&emsp;逆序迭代给定类型的链表
#### 参数
&emsp;&emsp;与{ref}`list_for_each_entry() <_list_for_each_entry>`相同
### `list_for_each_entry_safe(pos, n, head, member)`
#### 描述
&emsp;&emsp;从头开始迭代给定类型的链表(支持删除当前链表结点)
#### 参数
**pos**
&emsp;&emsp;指向特定类型的结构体的指针
**n**
&emsp;&emsp;用于存储临时值的和pos相同类型的指针
**head**
&emsp;&emsp;指向链表头结点的指针(struct List*)
**member**
&emsp;&emsp;struct List在pos的结构体中的成员变量名
### `list_prepare_entry(pos, head, member)`
#### 描述
&emsp;&emsp;为{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`准备一个'pos'结构体
#### 参数
**pos**
&emsp;&emsp;指向特定类型的结构体的,用作迭代起点的指针
**head**
&emsp;&emsp;指向要开始迭代的struct List结构体的指针
**member**
&emsp;&emsp;struct List在pos的结构体中的成员变量名
(_list_for_each_entry_continue)=
### `list_for_each_entry_continue(pos, head, member)`
#### 描述
&emsp;&emsp;从指定的位置的【下一个元素开始】,继续迭代给定的链表
#### 参数
**pos**
&emsp;&emsp;指向特定类型的结构体的指针。该指针用作迭代的指针。
**head**
&emsp;&emsp;指向要开始迭代的struct List结构体的指针
**member**
&emsp;&emsp;struct List在pos的结构体中的成员变量名
### `list_for_each_entry_continue_reverse(pos, head, member)`
#### 描述
&emsp;&emsp;从指定的位置的【上一个元素开始】,【逆序】迭代给定的链表
#### 参数
&emsp;&emsp;与{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`的相同
### `list_for_each_entry_from(pos, head, member)`
#### 描述
&emsp;&emsp;从指定的位置开始,继续迭代给定的链表
#### 参数
&emsp;&emsp;与{ref}`list_for_each_entry_continue() <_list_for_each_entry_continue>`的相同
(_list_for_each_entry_safe_continue)=
### `list_for_each_entry_safe_continue(pos, n, head, member)`
#### 描述
&emsp;&emsp;从指定的位置的【下一个元素开始】,继续迭代给定的链表.(支持删除当前链表结点)
#### 参数
**pos**
&emsp;&emsp;指向特定类型的结构体的指针。该指针用作迭代的指针。
**n**
&emsp;&emsp;用于存储临时值的和pos相同类型的指针
**head**
&emsp;&emsp;指向要开始迭代的struct List结构体的指针
**member**
&emsp;&emsp;struct List在pos的结构体中的成员变量名
### `list_for_each_entry_safe_continue_reverse(pos, n, head, member)`
#### 描述
&emsp;&emsp;从指定的位置的【上一个元素开始】,【逆序】迭代给定的链表。(支持删除当前链表结点)
#### 参数
&emsp;&emsp;与{ref}`list_for_each_entry_safe_continue() <_list_for_each_entry_safe_continue>`的相同
### `list_for_each_entry_safe_from(pos, n, head, member)`
#### 描述
&emsp;&emsp;从指定的位置开始,继续迭代给定的链表.(支持删除当前链表结点)
#### 参数
&emsp;&emsp;与{ref}`list_for_each_entry_safe_continue() <_list_for_each_entry_safe_continue>`的相同
---
## 基础C函数库