Implementation principle of redis (1) -- linked list

Source: Internet
Author: User

The linked list is a widely used data structure in redis. In many cases, the underlying structure of the list structure is implemented using the linked list.

The linked list is defined in the header file adlist. H. It is a common two-way linked list with the following structure:

1 // linked list Node 2 typedef struct listnode {3 struct listnode * Prev; // refers to the previous node 4 struct listnode * Next; // points to the next node 5 void * value; // value range 6} listnode; 7 // iteration pointer of linked list traversal 8 typedef struct listiter {9 listnode * Next; // next node pointer 10 int direction; // direction 11} listiter; 12 13 // chain table structure 14 typedef struct list {15 listnode * head; // head pointer of the chain table 16 listnode * tail; // The end pointer of the linked list 17 void * (* DUP) (void * PTR); // The Node value copying function pointer 18 void (* free) (void * PTR ); // node value range release function pointer 19 int (* match) (void * PTR, void * Key); // node value range comparison function pointer 20 unsigned long Len; // chain table length 21} List;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.