5. Skip list
論文
W. Pugh, “Skip Lists: A Probabilistic Alternative to Balanced
Trees,” Communications of the ACM 33, 6 (June 1990)
ちなみに、WADS ’89(workshop, Aug 1989)での発表が最初
特徴
勝手にバランスするバランス木
木といっても実際には多段なリスト構造
これまでの厳格なバランシング処理とは違い、確率を使って緩や
かなバランスを実現
データ構造とアルゴリズムの両面においてシンプル
ノードの挿入?削除を簡単に行える
既存のバランス木と比べ高速
Lock-freeな実装が存在する
8
20. Lock-free Skip List
M. Fomitchev , E. Ruppert, “Lock-free linked lists and skip lists,”
Proc of the 23th annual ACM symp, July 2004
23
21. ConcurrentSkipListMap
lock-free実装 (ソースを見ると書いてある)
* Head nodes Index nodes
* +-+ right +-+ +-+
* |2|---------------->| |--------------------->| |->null
* +-+ +-+ +-+
* | down | |
* v v v
* +-+ +-+ +-+ +-+ +-+ +-+
* |1|----------->| |->| |------>| |----------->| |------>| |->null
* +-+ +-+ +-+ +-+ +-+ +-+
* v | | | | |
24
* v | | | | |
* Nodes next v v v v v
* +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+
* | |->|A|->|B|->|C|->|D|->|E|->|F|->|G|->|H|->|I|->|J|->|K|->null
* +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+
*
* The base lists use a variant of the HM linked ordered set
* algorithm. See Tim Harris, "A pragmatic implementation of
* non-blocking linked lists"
* http://www.cl.cam.ac.uk/~tlh20/publications.html and Maged
* Michael "High Performance Dynamic Lock-Free Hash Tables and
* List-Based Sets"
* http://www.research.ibm.com/people/m/michael/pubs.htm. The
* basic idea in these lists is to mark the "next" pointers of
* deleted nodes when deleting to avoid conflicts with concurrent
* insertions, and when traversing to keep track of triples
* (predecessor, node, successor) in order to detect when and how
* to unlink these deleted nodes.