Redis has a flexible extension and gets a double-ended list with a table header complexity of O (1), which is divided into list and listNode2 components.
List
1typedefstructList {//Linked list2ListNode *head;//Linked list Header3ListNode *tail;//Chain Footer4 void* (*dup) (void*PTR);//copy function Pointers5 void(* Free)(void*PTR);//releasing the memory function pointer6 int(*match) (void*ptr,void*key);//Compare function Pointers7UnsignedLongLen//Linked list length8} list;
ListNode:
1 struct ListNode { 2 struct listnode *prev; precursor pointer 3 struct listnode *next; successor Pointer 4 void// node value 5 } ListNode;
The following are the implementation principles of a doubly linked list:
The meaning of the list structure exists:
1. The time complexity for getting the first and the trailing elements is O (1), and you can choose to traverse the linked list elements backwards or forwards
2. Get the number of elements time complexity is 0 (1), the number of elements can be quickly removed without traversing
REDIS data structure storage linked list design details (Redis design and implementation notes)