
(主要是画了个类图,下文都是照搬Oracle的文档)
1. Collection interfaces
- Collection - A group of objects. No assumptions are made about the order of the collection (if any) or whether it can contain duplicate elements.
- Set - The familiar set abstraction. No duplicate elements permitted. May or may not be ordered. Extends the
Collectioninterface. - List - Ordered collection, also known as a sequence. Duplicates are generally permitted. Allows positional access. Extends the
Collectioninterface. - Queue - A collection designed for holding elements before processing. Besides basic
Collectionoperations, queues provide additional insertion, extraction, and inspection operations. - Deque - A double ended queue, supporting element insertion and removal at both ends. Extends the
Queueinterface. - Map - A mapping from keys to values. Each key can map to one value.
- SortedSet - A set whose elements are automatically sorted, either in their natural ordering (see the Comparable interface) or by a Comparator object provided when a SortedSet instance is created. Extends the Set interface.
- SortedMap - A map whose mappings are automatically sorted by key, either using the natural ordering of the keys or by a comparator provided when a
SortedMapinstance is created. Extends theMapinterface. - NavigableSet - A
SortedSetextended with navigation methods reporting closest matches for given search targets. ANavigableSetmay be accessed and traversed in either ascending or descending order. - NavigableMap - A
SortedMapextended with navigation methods returning the closest matches for given search targets. ANavigableMapcan be accessed and traversed in either ascending or descending key order. - BlockingQueue - A
Queuewith operations that wait for the queue to become nonempty when retrieving an element and that wait for space to become available in the queue when storing an element. - TransferQueue - A
BlockingQueuein which producers can wait for consumers to receive elements. - BlockingDeque - A
Dequewith operations that wait for the deque to become nonempty when retrieving an element and wait for space to become available in the deque when storing an element. Extends both theDequeandBlockingQueueinterfaces. - ConcurrentMap - A
Mapwith atomic putIfAbsent, remove, and replace methods. - CocurrentNavigableMap - A
ConcurrentMapthat is also aNavigableMap.
2. General-purpose implementations
- HashSet - Hash table implementation of the
Setinterface. The best all-around implementation of theSetinterface. - TreeSet - Red-black tree implementation of the
NavigableSetinterface. - LinkedHashSet - Hash table and linked list implementation of the
Setinterface. An insertion-orderedSetimplementation that runs nearly as fast as HashSet. - ArrayList - Resizable array implementation of the
Listinterface (an unsynchronizedVector). The best all-around implementation of the List interface. - ArrayDeque - Efficient, resizable array implementation of the
Dequeinterface. - LinkedList - Doubly-linked list implementation of the
Listinterface. Provides better performance than theArrayListimplementation if elements are frequently inserted or deleted within the list. Also implements theDequeinterface. When accessed through theQueueinterface,LinkedListacts as a FIFO queue. - PriorityQueue -
Heapimplementation of an unbounded priority queue. - HashMap - Hash table implementation of the
Mapinterface (an unsynchronizedHashtablethat supports null keys and values). The best all-around implementation of the Map interface. - TreeMap - Red-black tree implementation of the
NavigableMapinterface. - LinkedHashMap - Hash table and linked list implementation of the
Mapinterface. An insertion-orderedMapimplementation that runs nearly as fast asHashMap. Also useful for building caches (see removeEldestEntry(Map.Entry) ).
3. Legacy implementations
- Vector - Synchronized resizable array implementation of the
List interface with additional legacy methods. - Hashtable - Synchronized hash table implementation of the
Mapinterface that does not allow null keys or values, plus additional legacy methods.
4. Special-purpose implementations
- WeakHashMap - An implementation of the
Mapinterface that stores only weak references to its keys. Storing only weak references enables key-value pairs to be garbage collected when the key is no longer referenced outside of theWeakHashMap. This class is the easiest way to use the power of weak references. It is useful for implementing registry-like data structures, where the utility of an entry vanishes when its key is no longer reachable by any thread. - IdentityHashMap Identity-based
Mapimplementation based on a hash table. This class is useful for topology-preserving object graph transformations (such as serialization or deep copying). To perform these transformations, you must maintain an identity-based "node table" that keeps track of which objects have already been seen. Identity-based maps are also used to maintain object-to-meta-information mappings in dynamic debuggers and similar systems. Finally, identity-based maps are useful in preventing "spoof attacks" resulting from intentionally perverse equals methods. (IdentityHashMap never invokes the equals method on its keys.) An added benefit of this implementation is that it is fast. - CopyOnWriteArrayList - A
Listimplementation backed by an copy-on-write array. All mutative operations (such asadd,set, andremove) are implemented by making a new copy of the array. No synchronization is necessary, even during iteration, and iterators are guaranteed never to throwConcurrentModificationException. This implementation is well-suited to maintaining event-handler lists (where change is infrequent, and traversal is frequent and potentially time-consuming). - CopyOnWriteArraySet - A
Setimplementation backed by a copy-on-write array. This implementation is similar toCopyOnWriteArrayList. Unlike mostSetimplementations, theadd,remove, andcontainsmethods require time proportional to the size of the set. This implementation is well suited to maintaining event-handler lists that must prevent duplicates. - EnumSet - A high-performance
Setimplementation backed by a bit vector. All elements of eachEnumSetinstance must be elements of a single enum type. - EnumMap - A high-performance Map implementation backed by an array. All keys in each EnumMap instance must be elements of a single enum type.
5. Concurrent implementations
- ConcurrentLinkedQueue - An unbounded first in, first out (FIFO) queue based on linked nodes.
- LinkedBlockingQueue - An optionally bounded FIFO blocking queue backed by linked nodes.
- ArrayBlockingQueue - A bounded FIFO blocking queue backed by an array.
- PriorityBlockingQueue - An unbounded blocking priority queue backed by a priority heap.
- DelayQueue - A time-based scheduling queue backed by a priority heap.
- SynchronousQueue - A simple rendezvous mechanism that uses the
BlockingQueueinterface. - LinkedBlockingDeque - An optionally bounded FIFO blocking deque backed by linked nodes.
- LinkedTransferQueue - An unbounded
TransferQueuebacked by linked nodes. - ConcurrentHashMap - A highly concurrent, high-performance
ConcurrentMapimplementation based on a hash table. This implementation never blocks when performing retrievals and enables the client to select the concurrency level for updates. It is intended as a drop-in replacement forHashtable. In addition to implementingConcurrentMap, it supports all of the legacy methods ofHashtable. - ConcurrentSkipListSet - Skips list implementation of the
NavigableSetinterface. - ConcurrentSkipListMap - Skips list implementation of the
ConcurrentNavigableMapinterface.
6. Utilities
- Arrays - Contains static methods to sort, search, compare, hash, copy, resize, convert to
String, and fill arrays of primitives and objects. - Collections - Consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection, and a few other odds and ends.
(完)
References: