Java 并发编程之 ConcurrentSkipListSet

Java juc About 1,085 words

介绍

线程安全的排序集合。

原理

ConcurrentSkipListSet底层是使用ConcurrentSkipListMap实现。

public ConcurrentSkipListSet() {
    m = new ConcurrentSkipListMap<E,Object>();
}

具体可参考前一篇文章:Java 并发编程之 ConcurrentSkipListMap

跳跃列表

Head nodes          Index nodes
+-+    right        +-+                      +-+
|2|---------------->| |--------------------->| |->null
+-+                 +-+                      +-+
 | down              |                        |
 v                   v                        v
+-+            +-+  +-+       +-+            +-+       +-+
|1|----------->| |->| |------>| |----------->| |------>| |->null
+-+            +-+  +-+       +-+            +-+       +-+
 v              |    |         |              |         |
Nodes  next     v    v         v              v         v
+-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+
| |->|A|->|B|->|C|->|D|->|E|->|F|->|G|->|H|->|I|->|J|->|K|->null
+-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+  +-+

put 示意图

Skip_list_add_elementen.gif

跳跃列表

https://en.wikipedia.org/wiki/Skip_list

Views: 1,564 · Posted: 2021-11-04

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh