list_add_tail()
2007-01-12 17:29
399 查看
将new所代表的list_head插入head所索引的队列的尾部
static inline void list_add_tail(struct list_head *new, struct list_head *head)
...{
__list_add(new, head->prev, head);
}
将new所代表的list_head插入到next索引的双链表(next索引双链表的第一个节点)的尾部
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
...{
next->prev = new; //(1)
new->next = next; //(2)
new->prev = prev; //(3)
prev->next = new; //(4)
}
next
new head----+----------------------------------------------+
| | |
| list_head | list_head list_head list_head |
| |---------| | |---------| |---------| |---------| |
+-->| *next | +--->| *next |-->| *next |-->| *next |---+
|---------| |---------| |---------| |---------|
| *prev | +--| *prev |<--| *prev |<--| *prev |<--+---prev
|---------| | |---------| |---------| |---------| |
| |
+--------------------------------------------+
+---------------------+
| next | (4)
new| head----+ +-----------------------------------------+
| | | |
+--+ list_head | list_head list_head list_head |
| |---------|(2) | |---------| |---------| |---------| |
+-->| *next |-----+--->| *next |-->| *next |-->| *next |---+
|---------| |---------| |---------| |---------|
+---| *prev |<---------| *prev |<--| *prev |<--| *prev |<--+---prev
| |---------| (1) |---------| |---------| |---------| |
| |
+------------------------------------------------------------------+
(3)
static inline void list_add_tail(struct list_head *new, struct list_head *head)
...{
__list_add(new, head->prev, head);
}
将new所代表的list_head插入到next索引的双链表(next索引双链表的第一个节点)的尾部
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
...{
next->prev = new; //(1)
new->next = next; //(2)
new->prev = prev; //(3)
prev->next = new; //(4)
}
next
new head----+----------------------------------------------+
| | |
| list_head | list_head list_head list_head |
| |---------| | |---------| |---------| |---------| |
+-->| *next | +--->| *next |-->| *next |-->| *next |---+
|---------| |---------| |---------| |---------|
| *prev | +--| *prev |<--| *prev |<--| *prev |<--+---prev
|---------| | |---------| |---------| |---------| |
| |
+--------------------------------------------+
+---------------------+
| next | (4)
new| head----+ +-----------------------------------------+
| | | |
+--+ list_head | list_head list_head list_head |
| |---------|(2) | |---------| |---------| |---------| |
+-->| *next |-----+--->| *next |-->| *next |-->| *next |---+
|---------| |---------| |---------| |---------|
+---| *prev |<---------| *prev |<--| *prev |<--| *prev |<--+---prev
| |---------| (1) |---------| |---------| |---------| |
| |
+------------------------------------------------------------------+
(3)
相关文章推荐
- list_add_tail
- list_add_tail()
- list_add_tail 双向链表实现分析
- list_add_tail()
- list_add_tail 双向链表实现分析 .
- list_add_tail 添加双向链表结点讲解
- clist addtail
- list 链表及list_add_tail 双向链表实现分析
- list 的add addall
- How to add elements to a List in Scala
- List之根据某个字段在add的时候过滤掉重复的数据
- list.add时的数据覆盖问题
- Arrays.asList()返回的List不能add和remove
- Add to List 121. Best Time to Buy and Sell Stock,我的解题思路
- Arrays.asList() 返回的list不能add,remove
- 安装android studio时候弹出unable to access android sdk add-on list解决方法
- 安装android studio时候弹出unable to access android sdk add-on list解决方法
- 安装 Android studio 运行 爆出 Unable to access Android SDK add-on list -...
- Arrays.toList(T[] t)返回的List不可执行add方法
- DWR如何获得返回对象 list Map Set list.add(JavaBean)