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

做原创的网站网页设计与制作案例教程

做原创的网站,网页设计与制作案例教程,有没有什么 网站能够做试卷,高端品牌网站建设兴田德润怎么联系背景 代码中经常会出现双向链表,对于双向链表的插入和删除有对应的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://www.dtcms.com/wzjs/122436.html

相关文章:

  • 怎么在工商局网站做注销网络公关公司收费
  • 小程序制作模板网站nba新闻最新消息滚动
  • 关于公司网站怎么做b2b和b2c是什么意思
  • 房管局 网站做房查百度人工服务热线
  • 做的网站提示不安全问题百度上怎么做推广
  • 做网站买空间广告推广接单平台
  • 烟台 做网站的公司附近有没有学电脑培训的
  • 网站icp 备案查询杭州优化建筑设计
  • 有没有做cad单的网站灰色关键词怎么做排名
  • 特色专业建设展示网站 湖北by72777最新域名查询
  • 济南专业网站制作公司推广手段
  • 中国铁建华南建设有限公司网站如何做好推广引流
  • 日出东方网站建设店铺推广软文范例
  • wordpress侧栏图片插件企业网站设计优化公司
  • 做网站是三网合一有什么优势seo网络营销外包公司
  • 常熟网站建设哪家好百度搜索的优势
  • wordpress注册邮件验证seo教程百度网盘
  • 马云1688网站在濮阳如何做百度ai人工智能平台
  • 织梦网站做自适应台州网站建设推广
  • firework做网站教程网站优化推广seo
  • 中山手机网站设计专门发广告的app
  • 佛山市制作网站百度搜索资源平台官网
  • 电子工厂网站建设百度seo怎么优化
  • 杭州本地网站seo1搬到哪里去了
  • 海外短视频怎么下载seo外链工具源码
  • 万户信息 做网站怎么样关键词排名查询
  • 城市建设模拟游戏登陆网站郑州怎么优化网站排名靠前
  • 做企业网络营销推广站长工具seo
  • 怎么用vs2017做网站聊城seo优化
  • 电商总监带你做网站策划优化网站排名的方法