Redis源码学习之【链表】
来源:互联网 发布:手机端网页小游戏源码 编辑:程序博客网 时间:2024/05/29 04:45
介绍
Redis自己实现了一个含有迭代器的双向链表。基本功能就是通用的双向链表,源码实现还是值得阅读以下的。
源文件
adlist.h adlist.c
分析
这里主要介绍其主要的数据结构其他的链表相关的操作有兴趣的话可以自己去看源码,其中的细节tricky还是挺多的。
- /* Node, List, and Iterator are the only data structures used currently. */
- /*
- * 链表节点
- */
- typedef struct listNode {
- // 前驱节点
- struct listNode *prev;
- // 后继节点
- struct listNode *next;
- // 值
- void *value;
- } listNode;
- /*
- * 链表迭代器
- */
- typedef struct listIter {
- // 下一节点
- listNode *next;
- // 迭代方向
- int direction;
- } listIter;
- /*
- * 链表
- */
- typedef struct list {
- // 表头指针
- listNode *head;
- // 表尾指针
- listNode *tail;
- // 节点数量
- unsigned long len;
- // 复制函数
- void *(*dup)(void *ptr);
- // 释放函数
- void (*free)(void *ptr);
- // 比对函数
- int (*match)(void *ptr, void *key);
- } list;
0 0
- Redis源码学习之【链表】
- Redis源码学习之【链表】
- Redis源码学习之【前言】
- Redis源码学习之【前言】
- redis源码学习之字典
- Redis 源码学习之 Redis 事务
- Redis源码学习之【动态字符串】
- Redis源码学习之【内存分配】
- Redis源码学习之【哈希字典】
- Redis源码学习之【事件机制】
- Redis源码学习之【epoll封装】
- Redis源码学习之【Tcp Socket封装】
- Redis源码学习之【网络通信框架】
- Redis源码学习之【命令协议格式】
- Redis源码学习之【暂停说明】
- Redis源码学习之【事件机制】
- Redis源码学习之【动态字符串】
- Redis源码学习之【哈希字典】
- 线程存储之pthread_key_create()
- 用Delphi编写Windows服务程序
- UML中几种类间的关系总结
- Android 应用程序共享签名的方法
- closet 与parents区别 1.7版closet已经删除
- Redis源码学习之【链表】
- Redis源码学习之【动态字符串】
- 润乾——列属性
- Activity的四种launchMode。
- select 模型例子代码
- Eclipse 设置作者等信息
- A1 = ? (数学归纳法)
- windows安装ZIP压缩版的Weblogic Server
- Redis源码学习之【哈希字典】