list_add_tail
2012-10-18 08:51
639 查看
【转】list_add_tail()
list_add_tail() 将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) |---------| |---------| |---------| |
| |
+------------------------------------------------------------------+
相关文章推荐
- list 链表及list_add_tail 双向链表实现分析
- list_add_tail 双向链表实现分析
- list_add_tail 添加双向链表结点讲解
- clist addtail
- list_add_tail()
- list_add_tail()
- list_add_tail()
- list_add_tail 双向链表实现分析 .
- JavaSE8基础 LinkedList<String> add与addLast方法效果相同
- Copy List with Random Pointer & Add Two Numbers & Valid Palindrome
- How to add a new "CustomAction" in ECB for a specific list
- 【leedcode】 Add to List 303. Range Sum Query - Immutable
- Add to List 442. Find All Duplicates in an Array(java)
- WPF中List的Add()与Insert()方法的区别
- Add to List 316. Remove Duplicate Letters
- 启动android studio时出现 unble to access android sdk add-on list 问题的解决办法
- Add to List 392. Is Subsequence
- 使用SingleLinkedList扩展类,允许Add,Remove,Contains
- 第一次安装android studio时候弹出unable to access android sdk add-on list解决方法
- 2. Add Two Numbers leetcode(list)