java源码解析S

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zl_1079167478/article/details/83271456

Set

A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction. – 不包含重复元素的集合,允许null

主要关注

  1. HashSet
  2. TreeSet
  3. ConcurrentSkipListSet

HashSet

特点: 底层原理就是HashMap,不过Set的元素作为Map的key。所以间接保证Set非重复,不连续,非线程安全

TreeSet

特点: 底层原理就是TreeMap,连续,非线程安全,TreeMap基于红黑树

ConcurrentSkipListSet

特点: 底层原理就是ConcurrentNavigableMap,连续,线程安全,线程安全的有序的集合,适用于高并发的场景。

猜你喜欢

转载自blog.csdn.net/zl_1079167478/article/details/83271456