结构
reids的list采用的是双向链表的实现,未使用dummy node。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| 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; void *(*dup)(void *ptr); void (*free)(void *ptr); int (*match)(void *ptr, void *key); unsigned long len; } list;
|
特点
- 双端
- 无环
- 有头尾指针
- 有长度计数器
- 多态(使用
void*
来保存节点值,并提供free
,dup
,match
来处理节点)