list add tail 新增雙向鍊錶結點講解

2021-06-06 14:56:13 字數 1129 閱讀 4079

我是在看linux 的input subsystem 的時候,用到的這個函式,當時我對鍊錶還不怎麼清楚

struct list_head ;

list_add_tail(&dev->node, &input_dev_list);

/*** list_add_tail - add a new entry

* @new: new entry to be added

* @head: list head to add it before

** insert a new entry before the specified head.

* this is useful for implementing queues.

*/static __inline__ void list_add_tail(struct list_head *_new, struct list_head *head)

/** insert a new entry between two known consecutive entries.

** this is only for internal list manipulation where we know

* the prev/next entries already!

*/static __inline__ void __list_add(struct list_head * _new,

struct list_head * prev,

struct list_head * next)

其實這個函式完成的功能就是新增乙個新的結點在head的左邊,我接下來,詳解講解新增的過程

開始的時候,我們只知道有乙個乙個頭節點,struct list_head *head,然後將next->prev = _new;

_new->next = next;這就是將new節點新增到head 節點的左邊,那麼接    _new->prev = prev;

prev->next = _new這兩個是什麼意思呢??/

因為開始head->pre->next是指向head的,因為現在新增了乙個新的節點了,而且是在左邊新增的,所以現在就需要將head->pre->next指向新的節點,而將新的節點的pre,也就是new->pre指向以前指向head的節點

list add tail 雙向鍊錶實現分析

在看核心v4l2示例 driver media video vivi.c時 看到list add tail 函式,現在對其進行分析 cpp view plain copy print?struct list head list add tail buf vb.queue,vid active lis...

Tomcat新增HTTPS單向認證和雙向認證

前言 在tomcat的根目錄下找到 conf server.xml檔案開啟,找到如下位置 修改為如下內容 這段配置中keystorefile c install keystore keystorepass server 需要根據自己的證書進行調整,其中keystorefile 可以使用相對路徑 現在...

雙向迴圈鍊錶的建立 查詢 新增 刪除

雙向迴圈鍊錶的建立 查詢 新增 刪除 include include typedef struct lnodelnode,dlinklist 尾插法建立雙向鍊錶 dlinklist create dlinklist l,int n return l void menu 獲取雙向迴圈鍊錶中某一元素的值...