ConcurrentSkipListSet

特性

public class ConcurrentSkipListSet<E>
    extends AbstractSet<E>
    implements NavigableSet<E>, Cloneable, java.io.Serializable {}

前面都概述过,不做过多赘述

基本属性

//基于ConcurrentNavigableMap的存储
private final ConcurrentNavigableMap<E,Object> m;

//内存偏移量
private static final sun.misc.Unsafe UNSAFE;
    private static final long mapOffset;
    static {
        try {
            UNSAFE = sun.misc.Unsafe.getUnsafe();
            Class<?> k = ConcurrentSkipListSet.class;
            mapOffset = UNSAFE.objectFieldOffset
                (k.getDeclaredField("m"));
        } catch (Exception e) {
            throw new Error(e);
        }
    }

ConcurrentNavigableMap
java.util.concurrent.ConcurrentNavigableMap接口是ConcurrentMap接口的子接口,并且支持NavigableMap操作,并且递归地支持其可导航的子地图和近似匹配

public interface ConcurrentNavigableMap<K,V>
    extends ConcurrentMap<K,V>, NavigableMap<K,V>
{}

构造方法

ConcurrentSkipListSet的实现是基于ConcurrentSkipListMap的实现,crud方法在ConcurrentSkipListMap中进行概述

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

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

public ConcurrentSkipListSet(Collection<? extends E> c) {
        m = new ConcurrentSkipListMap<E,Object>();
        addAll(c);
    }

public ConcurrentSkipListSet(SortedSet<E> s) {
        m = new ConcurrentSkipListMap<E,Object>(s.comparator());
        addAll(s);
    }
©️2020 CSDN 皮肤主题: 像素格子 设计师:CSDN官方博客 返回首页