当前位置:网站首页>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
边栏推荐
- Voice data annotation tools and platforms
- Mysql, how to calculate the maximum value using stored procedures
- Signature analysis of app x-zse-96 in a Q & a community
- 不止于观测|阿里云可观测套件正式发布
- 【综合笔试题】30. 串联所有单词的子串
- Meta称英安全法可能“扫描所有私人信息” 或侵犯隐私
- 華為雲如何實現實時音視頻全球低時延網絡架構
- Attack and defense drill collection | 3 stages, 4 key points, interpretation of the blue team defense whole process outline
- 语音数据标注工具与平台
- 汉源高科USB3.0光端机USB工业触摸屏光端机USB3.0光纤延长器USB3.0光纤传输器
猜你喜欢

Rancher 2.6 全新 Monitoring 快速入门

Vone新闻 | 旺链科技赋能众享链网自组织管理,打造企业级联盟DAO

At 14:00 today, 12 Chinese scholars started ICLR 2022

全国进入主汛期,交通运输部:不具备安全运行条件的线路坚决停运!

六维图剖析:中国建筑集团有限公司企业成长性分析

开发增效利器—2022年VsCode插件分享

32路电话+2路千兆以太网32路PCM电话光端机支持FXO口FXS语音电话转光纤

navicat定时任务无效

How Huawei cloud implements a global low latency network architecture for real-time audio and video

4E1 PDH光端机19英寸机架式单纤传输20km E1接口光纤网络光端机
随机推荐
网上注册股票开户很困难么?现在网上开户安全么?
切比雪夫不等式证明及应用
开发增效利器—2022年VsCode插件分享
I am in Foshan. Where can I open an account? Is it safe to open a mobile account?
塔米狗 | 投资人类型分析以及企业投资类型分析
32路电话+2路千兆以太网32路PCM电话光端机支持FXO口FXS语音电话转光纤
Tensorrt筆記(四)推理分割模型
股票网上开户及开户流程怎样?手机开户安全么?
使用单调栈解题
Which securities company has the lowest Commission for opening a mobile account? Is it safe to open an account online now?
汉源高科1路千兆光口转4路千兆以太网电口千兆1光4电光纤收发器
One picture decoding opencloudos community open day
杜邦分析法解读:安阳钢铁股份有限公司企业投资价值何在?
Numbers that only appear once < difficulty coefficient > & Yang Hui triangle < difficulty coefficient >
Necessary software for automation or electrical specialty
十大劵商如何开户?在线开户安全么?
Go 语言使用 MySQL 的常见故障分析和应对方法
简单易懂的软路由刷机使用教程
How to use note taking software flowus and note for interval repetition? Based on formula template
Vone新闻 | 旺链科技赋能众享链网自组织管理,打造企业级联盟DAO