集合类源码(一)概述

一个简单知识点,List和Set都是继承Collection接口,HashMap实现了Map接口,而这两个顶级接口的实现类都有哪些呢?

Collection<E>

子接口:BlockingDeque<E>, BlockingQueue<E>, Deque<E>, List<E>, NavigableSet<E>, Queue<E>, Set<E>, SortedSet<E>, TransferQueue<E>

BlockingDeque<E>【双向阻塞队列】

实现类:LinkedBlockingDeque

BlockingQueue<E>【阻塞队列】

实现类:ArrayBlockingQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedTransferQueue, PriorityBlockingQueue, SynchronousQueue

Deque<E>【双向队列】

实现类:ArrayDeque, ConcurrentLinkedDeque, LinkedBlockingDeque, LinkedList

List<E>【有序列表】

实现类:AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector

NavigableSet<E>【SortedSet的扩展】

实现类:ConcurrentSkipListSet, TreeSet

Queue<E>【队列】

实现类:AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingDeque, LinkedBlockingQueue, LinkedList, LinkedTransferQueue, PriorityBlockingQueue, PriorityQueue, SynchronousQueue

Set<E>【集合】

实现类:AbstractSet, ConcurrentHashMap.KeySetView, ConcurrentSkipListSet, CopyOnWriteArraySet, EnumSet, HashSet, JobStateReasons, LinkedHashSet, TreeSet

SortedSet<E>【有序集合】

实现类:ConcurrentSkipListSet, TreeSet

TransferQueue<E>【一个BlockingQueue,其中生产者可以等待消费者接收元素】

实现类:LinkedTransferQueue

结构图:

=======================================================================================================================================

Map<K,V>

子接口:Bindings, ConcurrentMap<K,V>, ConcurrentNavigableMap<K,V>, NavigableMap<K,V>, SortedMap<K,V>
实现类:AbstractMap<K,V>, Hashtable<K,V>, LinkedHashMap<K,V>

Bindings【一个key为string类型的key/value映射类型】

实现类:SimpleBindings

ConcurrentMap<K,V>【线程安全Map】

实现类:ConcurrentHashMap, ConcurrentSkipListMap

ConcurrentNavigableMap<K,V>【支持NavigableMap操作的ConcurrentMap】

实现类:ConcurrentSkipListMap

NavigableMap<K,V>【SortedMap的扩展】

实现类:ConcurrentSkipListMap, TreeMap

SortedMap<K,V>【有序Map】

实现类:ConcurrentSkipListMap, TreeMap

AbstractMap<K,V>【抽象Map】

实现类:ConcurrentHashMap, ConcurrentSkipListMap, EnumMap, HashMap, IdentityHashMap, TreeMap, WeakHashMap

Hashtable<K,V>【线程安全Map】

实现类:Properties, UIDefaults

接下来的文章会从功能、原理、优缺点三个方面来阐述上述所有实现类

 

posted @ 2019-11-25 16:39  露娜妹  阅读(196)  评论(0编辑  收藏  举报