Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Rather than getting into more details about all the interfaces, we thought it would be helpful to first discuss the concrete data structures that the Java library supplies. Once we have thoroughly described the classes you might want to use, we will return to abstract considerations and see how the collections framework organizes these classes. Table 13–1 shows the collections in the Java library and briefly describes the purpose of each collection class. (For simplicity, we omit the thread-safe collections that will be discussed in Chapter 14.) All classes in Table 13–1 implement the Collection interface, with the exception of the classes with names ending in Map. Those classes implement the Map interface instead. We will discuss the Map interface in the section “Maps” on page 680.
| Collection Type | Description | See Page |
|---|---|---|
| ArrayList | An indexed sequence that grows and shrinks dynamically | 668 |
| LinkedList | An ordered sequence that allows efficient insertions and removal at any location | 659 |
| ArrayDeque | A double-ended queue that is implemented as a circular array | 678 |
| HashSet | An unordered collection that rejects duplicates | 668 |
| TreeSet | A sorted set | 672 |
| EnumSet | A set of enumerated type values | 687 |
| LinkedHashSet | A set that remembers the order in which elements were inserted | 686 |
| PriorityQueue | A collection that allows efficient removal of the smallest element | 679 |
| HashMap | A data structure that stores key/value associations | 680 |
| TreeMap | A map in which the keys are sorted | 680 |
| EnumMap | A map in which the keys belong to an enumerated type | 687 |
| LinkedHashMap | A map that remembers the order in which entries were added | 686 |
| WeakHashMap | A map with values that can be reclaimed by the garbage collector if they are not used elsewhere | 685 |
| IdentityHashMap | A map with keys that are compared by ==, not equals | 688 |