摘要: @ 5. HyperLogLog 实现 hyperloglog.c 数据结构定义 hllhdr struct hllhdr { char magic[4]; /* "HYLL" */ uint8_t encoding; /* HLL_DENSE or HLL_SPARSE. */ uint8_t n 阅读全文
posted @ 2021-06-09 23:20 Jamgun 阅读(102) 评论(0) 推荐(0)
摘要: @ 4. 跳表实现 redis.h 和 t_zset.c 数据结构定义 object // 包含 meta 和 数据 指针 #define REDIS_LRU_BITS 24 typedef struct redisObject { unsigned type:4; // 类型 unsigned e 阅读全文
posted @ 2021-06-09 23:17 Jamgun 阅读(88) 评论(0) 推荐(0)
摘要: 4. 字典实现 dict.h 和 dict.c 数据结构定义 状态码 #define DICT_OK 0 // 操作成功 #define DICT_ERR 1 // 操作失败(或出错) 哈希表kv节点 typedef struct dictEntry { void *key; // 键 union 阅读全文
posted @ 2021-06-09 22:56 Jamgun 阅读(63) 评论(0) 推荐(0)
摘要: 3. 双端链表 adlist.h 和 adlist.c 数据结构定义 节点 // 节点 typedef struct listNode { struct listNode *prev; struct listNode *next; void *value; } listNode; 链表 // 链表 阅读全文
posted @ 2021-06-09 22:36 Jamgun 阅读(97) 评论(0) 推荐(0)
摘要: 2. 动态字符串 sds.h 和 sds.c 数据结构定义 抽象 字符串 typedef char *sds; struct sdshdr { // 跟内存管理类似,加上prefix维护size信息 int len; // buf 中已占用空间的长度 int free; // buf 中剩余可用空间 阅读全文
posted @ 2021-06-09 22:30 Jamgun 阅读(66) 评论(0) 推荐(0)
摘要: 1. 内存管理**malloc和free** void *zmalloc(size_t size); // 对malloc的封装 void *zcalloc(size_t size); // 对calloc的封装 void *zrealloc(void *ptr, size_t size); // 阅读全文
posted @ 2021-06-09 22:22 Jamgun 阅读(57) 评论(0) 推荐(0)
摘要: 是什么 一个算法 论文指路 可视化展示 作用 估计集合的基数(去重元素个数) [a,b,c,d] 的基数是 4 [a,b,c,d,a] 的基数还是 4 原理 概率论的伯努利实验 + 修正 让我们玩一个游戏 你来掷硬币,我来猜你掷了多少回合 每回合规定,直到掷出反面结束,否则一直掷 比如你可以一直掷正 阅读全文
posted @ 2021-06-09 22:06 Jamgun 阅读(154) 评论(0) 推荐(0)