集合类源码(一)概述

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

Collection

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

BlockingDeque【双向阻塞队列】

实现类:LinkedBlockingDeque

BlockingQueue【阻塞队列】

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

Deque【双向队列】

实现类:ArrayDeque, ConcurrentLinkedDeque, LinkedBlockingDeque, LinkedList

List【有序列表】

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

NavigableSet【SortedSet的扩展】

实现类:ConcurrentSkipListSet, TreeSet

Queue【队列】

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

Set【集合】

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

SortedSet【有序集合】

实现类:ConcurrentSkipListSet, TreeSet

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

实现类:LinkedTransferQueue

结构图:

集合类源码(一)概述_第1张图片

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

Map

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

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

实现类:SimpleBindings

ConcurrentMap【线程安全Map】

实现类:ConcurrentHashMap, ConcurrentSkipListMap

ConcurrentNavigableMap【支持NavigableMap操作的ConcurrentMap】

实现类:ConcurrentSkipListMap

NavigableMap【SortedMap的扩展】

实现类:ConcurrentSkipListMap, TreeMap

SortedMap【有序Map】

实现类:ConcurrentSkipListMap, TreeMap

AbstractMap【抽象Map】

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

Hashtable【线程安全Map】

实现类:Properties, UIDefaults

集合类源码(一)概述_第2张图片

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

 

你可能感兴趣的:(集合类源码(一)概述)