当前位置:网站首页>Getting started with redis - Chapter 2 - data structures and objects - linked lists
Getting started with redis - Chapter 2 - data structures and objects - linked lists
2022-06-23 11:44:00 【tiger’s bytes】
The list is in Redis It is widely used in , For example, one of the underlying implementations of the list key is the linked list . When a list key contains a large number of elements , Or when the elements in the list are relatively long strings ,Redis Will use the linked list as the underlying implementation of the list key .
The realization of linked list and linked list node :
typedef struct listNode {
struct listNode * prev; // Front node pointer
struct listNode * next; // Post node pointer
void * value; // Node values
}listNode;typedef struct list {
listNode * head; // Header node
listNode * tail; // Tail node
unsigned long len; // Number of nodes
void *(*dup)(void *ptr); // Node copy function
void (*free)(void *ptr); // Node release function
void (*match)(void *ptr, void *key); // Node value comparison function
}list;
Redis The linked list implementation of can be summarized as :
- Two ends : Linked list nodes have prev and next The pointer , The time complexity of obtaining the pre node and post node of a node is O(1)
- acyclic : Of the header node prev And at the end of the table next The hands all point to NULL, Access to the linked list NULL End point
- Pointer with header and footer : adopt list Of head and tail Property to obtain the header and footer nodes. The time complexity is O(1)
- With linked list length counter : adopt list Of len attribute , The time complexity of obtaining the number of linked list nodes is O(1)
- polymorphic : Linked list usage void * Pointer to save the node value , And through list Structural dup、free、match Three properties set type specific functions for node values , So linked lists can be used to store various types of data
边栏推荐
- 运行时应用自我保护(RASP):应用安全的自我修养
- 自动化或电气专业必备软件
- KDD 2022 | 基于分层图扩散学习的癫痫波预测
- Oversampling series I: sampling theorem and oversampling rate
- 网上注册股票开户很困难么?现在网上开户安全么?
- 2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
- 如何在 FlowUs、Notion 等笔记软件中使用间隔重复记忆系统?
- Deep analysis and Simulation of list
- How does easygbs solve the abnormal use of intercom function?
- 【云驻共创】华为云HCIA-IoT V2.5培训系列内容之物联网概览
猜你喜欢
随机推荐
Go 语言使用 MySQL 的常见故障分析和应对方法
OpenHarmony应用开发【01】
Groovy之范围
【ML】QuantileRegressor
At 14:00 today, 12 Chinese scholars started ICLR 2022
【零基础微信小程序】基于百度大脑人像分割的证件照换底色小程序实战开发
The country has entered the main flood season. The Ministry of transport: the lines that do not meet the conditions for safe operation will be resolutely shut down!
十大劵商如何开户?在线开户安全么?
Meta称英安全法可能“扫描所有私人信息” 或侵犯隐私
Gradienttape of tensorflow2
Daily question 7-1652 Defuse the bomb
華為雲如何實現實時音視頻全球低時延網絡架構
Surprise! Amd acquires Xilinx with USD 35billion!
运行时应用自我保护(RASP):应用安全的自我修养
How does easygbs solve the abnormal use of intercom function?
Tensorrt筆記(四)推理分割模型
Vous comprenez vraiment la capacité de sortie de LDO!?
你真的理解LDO的輸出電容嗎!?
【云驻共创】无码时代,软件开发如何走向每个人?
4路电话+1路千兆以太网4路PCM电话光端机




![[processes and threads]](/img/6b/ff1076a3809ecc412f2bf6517c278e.png)




