当前位置: 首页 > wzjs >正文

简单的cms建站系统python培训班

简单的cms建站系统,python培训班,米课wordpress建站,传奇霸业官网下载背景 代码中经常会出现双向链表,对于双向链表的插入和删除有对应的API函数接口,但直观的图表更容易理解,所以本文会对rt-thread内核代码中提供的双向链表的一些API函数操作进行绘图,方便后续随时查看。 代码块 rt-thread中提供…

背景

代码中经常会出现双向链表,对于双向链表的插入和删除有对应的API函数接口,但直观的图表更容易理解,所以本文会对rt-thread内核代码中提供的双向链表的一些API函数操作进行绘图,方便后续随时查看。

代码块

rt-thread中提供的代码段包括:
链表定义rtdef.h

/*** Double List structure*/
struct rt_list_node
{struct rt_list_node *next;                          /**< point to next node. */struct rt_list_node *prev;                          /**< point to prev node. */
};
typedef struct rt_list_node rt_list_t;                  /**< Type for lists. */

API操作定义rtserver.h

/*** @addtogroup KernelService*//**@{*//*** rt_container_of - return the start address of struct type, while ptr is the* member of struct type.*/
#define rt_container_of(ptr, type, member) \((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))/*** @brief initialize a list object*/
#define RT_LIST_OBJECT_INIT(object) { &(object), &(object) }/*** @brief initialize a list** @param l list to be initialized*/
rt_inline void rt_list_init(rt_list_t *l)
{l->next = l->prev = l;
}/*** @brief insert a node after a list** @param l list to insert it* @param n new node to be inserted*/
rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
{l->next->prev = n;n->next = l->next;l->next = n;n->prev = l;
}/*** @brief insert a node before a list** @param n new node to be inserted* @param l list to insert it*/
rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n)
{l->prev->next = n;n->prev = l->prev;l->prev = n;n->next = l;
}/*** @brief remove node from list.* @param n the node to remove from the list.*/
rt_inline void rt_list_remove(rt_list_t *n)
{n->next->prev = n->prev;n->prev->next = n->next;n->next = n->prev = n;
}/*** @brief tests whether a list is empty* @param l the list to test.*/
rt_inline int rt_list_isempty(const rt_list_t *l)
{return l->next == l;
}/*** @brief get the list length* @param l the list to get.*/
rt_inline unsigned int rt_list_len(const rt_list_t *l)
{unsigned int len = 0;const rt_list_t *p = l;while (p->next != l){p = p->next;len ++;}return len;
}/*** @brief get the struct for this entry* @param node the entry point* @param type the type of structure* @param member the name of list in structure*/
#define rt_list_entry(node, type, member) \rt_container_of(node, type, member)/*** rt_list_for_each - iterate over a list* @pos:    the rt_list_t * to use as a loop cursor.* @head:   the head for your list.*/
#define rt_list_for_each(pos, head) \for (pos = (head)->next; pos != (head); pos = pos->next)/*** rt_list_for_each_safe - iterate over a list safe against removal of list entry* @pos:    the rt_list_t * to use as a loop cursor.* @n:      another rt_list_t * to use as temporary storage* @head:   the head for your list.*/
#define rt_list_for_each_safe(pos, n, head) \for (pos = (head)->next, n = pos->next; pos != (head); \pos = n, n = pos->next)/*** rt_list_for_each_entry  -   iterate over list of given type* @pos:    the type * to use as a loop cursor.* @head:   the head for your list.* @member: the name of the list_struct within the struct.*/
#define rt_list_for_each_entry(pos, head, member) \for (pos = rt_list_entry((head)->next, typeof(*pos), member); \&pos->member != (head); \pos = rt_list_entry(pos->member.next, typeof(*pos), member))/*** rt_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry* @pos:    the type * to use as a loop cursor.* @n:      another type * to use as temporary storage* @head:   the head for your list.* @member: the name of the list_struct within the struct.*/
#define rt_list_for_each_entry_safe(pos, n, head, member) \for (pos = rt_list_entry((head)->next, typeof(*pos), member), \n = rt_list_entry(pos->member.next, typeof(*pos), member); \&pos->member != (head); \pos = n, n = rt_list_entry(n->member.next, typeof(*n), member))/*** rt_list_first_entry - get the first element from a list* @ptr:    the list head to take the element from.* @type:   the type of the struct this is embedded in.* @member: the name of the list_struct within the struct.** Note, that list is expected to be not empty.*/
#define rt_list_first_entry(ptr, type, member) \rt_list_entry((ptr)->next, type, member)

重点函数

rt_list_init()
rt_list_insert_after()
rt_list_insert_before()
rt_list_remove()

重点函数理解

rt_list_init(rt_list_t *l)

rt_inline void rt_list_init(rt_list_t *l)
{l->next = l->prev = l;
}

初始化当前链表l,即当前链表l的pre和next都是指向自己。
在这里插入图片描述

rt_list_insert_after(rt_list_t *l, rt_list_t *n)

rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
{l->next->prev = n;n->next = l->next;l->next = n;n->prev = l;
}

将新链表n1插入到l之后
在这里插入图片描述
将新链表n2插入到l之后
在这里插入图片描述
将新链表n3插入到l之后
在这里插入图片描述

rt_list_insert_before(rt_list_t *l, rt_list_t *n)

rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n)
{l->prev->next = n;n->prev = l->prev;l->prev = n;n->next = l;
}

将新链表n1插入到l之前
在这里插入图片描述
将新链表n2插入到l之前
在这里插入图片描述

rt_list_remove(rt_list_t *n)

rt_inline void rt_list_remove(rt_list_t *n)
{n->next->prev = n->prev;n->prev->next = n->next;n->next = n->prev = n;
}

从已有链表中移除当前链表,如原链表
在这里插入图片描述
从此链表中移除n2,则
在这里插入图片描述


文章转载自:

http://lj6C1IET.xffns.cn
http://5QoEgUDv.xffns.cn
http://WTzcvlxe.xffns.cn
http://8Jr7ouoR.xffns.cn
http://YyAyR6JU.xffns.cn
http://nd6WzA3l.xffns.cn
http://0y53NbhC.xffns.cn
http://HZUVNbIX.xffns.cn
http://f9CtyJdL.xffns.cn
http://yIcEeTuZ.xffns.cn
http://h09xt988.xffns.cn
http://jQ52GvJL.xffns.cn
http://253pZBKy.xffns.cn
http://qbPB1JUw.xffns.cn
http://PRbJwLHi.xffns.cn
http://SCktZ2Qs.xffns.cn
http://qzGm9KNe.xffns.cn
http://gtx4IE3W.xffns.cn
http://QQ6yroyH.xffns.cn
http://9GEuQ6Tm.xffns.cn
http://m2dKvUK1.xffns.cn
http://bppGbTvU.xffns.cn
http://yjFFDGHp.xffns.cn
http://VGz62KXT.xffns.cn
http://LwNGGTbV.xffns.cn
http://XHm6riZn.xffns.cn
http://XdYFDzoB.xffns.cn
http://qhETk2pn.xffns.cn
http://wd19yXmi.xffns.cn
http://5DNVl4If.xffns.cn
http://www.dtcms.com/wzjs/697317.html

相关文章:

  • 建设 网站工作汇报做网站的一般多钱
  • 管理网站制作wordpress国内主题排行
  • 网站建设一般多少钱新闻网站建设预付款
  • 电商网站建设培训学校小说网站排名
  • 网站建设费一般多少钱给我免费播放电影
  • 什么做网站赚钱搜索引擎营销就是seo
  • 怎么看网站做的外链php微信公众号开发教程
  • wordpress做分类网站建设局和住建局的区别
  • 网站建设主要推广方式张家港早晨网站制作
  • 图书馆第一代网站建设专业网站托管的公司
  • 仿站违法吗门店设计装修效果图
  • 网站基本信息设置什么叫做响应式网站
  • 深圳公司开发网站网站建设与开发
  • 网站图片如何做缓存做i爱小说网站
  • 北京 网站建设目前免费的h5制作软件
  • 网站开发的套路百度网站的结构
  • 吴江区建设工程招标网站360收录提交入口网址
  • 沈阳网站建设制作wordpress 评论群发
  • 单位门户网站建设方案江苏省建设工程招标网官网
  • 前端网站建设深圳大浪有做网站的吗
  • 黄石网站设计公司西电信息化建设处网站
  • 购物网站设计理念熟悉网页设计人机交互实验报告
  • 电子商务网站建设域名做网站便宜还是app便宜
  • 宁津做网站免费ppt模板下载不用钱的
  • 漳州公司做网站做网站优化最快的方式
  • 如何让网站排名下降win7云主机怎么做网站
  • 家教中介怎么利用网站来做的北京seo工程师
  • 苏州做网站推广做网站赚钱平台
  • wordpress怎么写网站关键词和描述怎么修改自己网站内容
  • 游戏网站建设与策划方案网站seo优化报告