《Redis 设计与实现》笔记 - 跳跃表
Java 中的跳跃表 - ConcurrentSkipListMap
数据结构
/**
* Nodes hold keys and values, and are singly linked in sorted
* order, possibly with some intervening marker nodes. The list is
* headed by a header node accessible as head.node. Headers and
* marker nodes have null keys. The val field (but currently not
* the key field) is nulled out upon deletion.
*/
static final class Index<K,V> {
final Node<K,V> node; // currently, never detached
final Index<K,V> down;
Index<K,V> right;
Index(Node<K,V> node, Index<K,V> down, Index<K,V> right) {
this.node = node;
this.down = down;
this.right = right;
}
}
/**
* Index nodes represent the levels of the skip list.
*/
static final class Node<K,V> {
final K key; // currently, never detached
V val;
Node<K,V> next;
Node(K key, V value, Node<K,V> next) {
this.key = key;
this.val = value;
this.next = next;
}
}Redis 中的跳跃表
数据结构
zskiplistNoe
zskiplistlist
最后更新于