Linux List_head list.h

1. What is doubly linked list? Each family has a grandfather 0, 0 father, son, 0, 0 grandmother, my mother 0, 0 daughter. 0 grandfather also has its own Mom and Dad 1 1 0 grandmother also have their own mom and dad 1 1.

Dad 0 0 Information of his head had a son, there is information in the list, the father found his son 0 0 by the list pointer (that addresses). 0 father wanted his father how to do, then the head of the information, find grandfather 0 is a very easy thing in the list. That is, Dad can look forward, you can also find backward. This is doubly linked list. Of course, my mother, too. The final step is a mixed network.


2. What are the cornerstone of a doubly linked list is? Of course, no doubt is a pointer (address). As the postal system, like the address of each household the various letters, gifts, fruits, Taobao variety of wonderful items to each individual hands.


3. doubly linked list is generally used where? VLC playlist can be placed in a doubly linked list; IPC Buffer video information can be placed in a doubly linked list; ATM withdrawals each step is a doubly linked list in trouble, if you are not happy day, "ATM processes too rigid, if the card is not required, see eye to spit good money ", then this time you need to use an algorithm similar to the deep learning of information to detect human faces, and then paired according to the information stored in the database, the pairing process will certainly involve the list.


4. On the Linux / Unix / windows programming, List is so common:

include/list.h

1. INIT_LIST_HEAD (ptr); // initialize a doubly linked list head

2. list_add (struct list_head * new, struct list_head * head); // after the new node is added to the head, the first node as a search backwards Head

3. list_add_tail (struct list_head * add, struct list_head * head); // new node is added to the previously Head, Head search forward as the first node

4. list_del (struct list_head * entry); // delete a node (list_del_init (struct list_head * entry))

5. list_empty (struct list_head * head); // determines whether the list is empty

List_for_each 6. The (POS, head ); // traverse the list, delete node operation at this time may be wrong

7. list_for_each_safe (pos, pnext, head); // traverse the list, there may be operating simultaneously delete nodes

// obtain data items traversing the list; 8. list_entry (ptr, type, member)

9. list_for_each_entry (pos, head, member); // edge traverse the list, while taking data. 6,7,8 combination


Icekirin.yuan - Kirin studio Addict

Q group: 147 565 042



Published 14 original articles · won praise 8 · views 20000 +

Guess you like

Origin blog.csdn.net/YXFLINUX/article/details/51860125