English | 中文版
[TOC]
| Function | Purpose | Time Complexity |
|---|---|---|
| listSetDupMethod | Set the list node value duplication function | Dup function is available via the list's dup property, |
| listGetDupMethod | Return the currently used node value duplication function | |
| listSetFreeMethod | Set the list node value deallocation function | Free function is available via the list's free property, |
| listGetFree | Return the currently used node value deallocation function | |
| listGetMatchMethod | Return the currently used node value comparison function | |
| listLength | Return the length of the list (number of nodes) | Length is available via the list's len property, |
| listFirst | Return the head node of the list | Head is available via the list's head property, |
| listLast | Return the tail node of the list | Tail is available via the list's tail property, |
| listPrevNode | Return the previous node of a given node | Prev is available via node's prev property, |
| listNextNode | Return the next node of a given node | Next is available via node's next property, |
| listNodeValue | Return the value currently stored in a given node | Value is available via node's value property, |
| listCreate | Create a new empty list | |
| listAddNodeHead | Add a new node containing the given value to the list head | |
| listAddNodeTail | Add a new node containing the given value to the list tail | |
| listInsertNode | Insert a new node with the given value before or after a node | |
| listSearchKey | Find and return the node that contains the given value |
|
| listIndex | Return the node at the given index in the list |
|
| listDelNode | Delete the given node from the list |
|
| listRotate | Pop the tail node and insert it at the head (new head) | |
| listDup | Duplicate a given list |
|
| listRelease | Free the given list and all its nodes |
|
typedef struct listNode { // list node
struct listNode *prev; // previous node
struct listNode *next; // next node
void *value; // node value
} listNode;typedef struct listIter { // list iterator
listNode *next; // pointer to next
int direction; // direction
} listIter;
// iterator directions
#define AL_START_HEAD 0 // from head
#define AL_START_TAIL 1 // from tailtypedef struct list { // doubly linked list
listNode *head; // head node
listNode *tail; // tail node
void *(*dup)(void *ptr); // node value duplication function
void (*free)(void *ptr); // node value free function
int (*match)(void *ptr, void *key); // node value comparison function
unsigned long len; // number of nodes
} list;[1] Huang Jianhong. Redis Design and Implementation