Java Reference
In-Depth Information
LinkedHashMap<K,V> : Implements a map storing values of type V using keys of type K with all of
its entries in a doubly-linked list. This class can be used to create a copy of a map of any type such
that the order of the entries in the copy is the same as the original.
WeakHashMap<K,V> : Implements a map storing values of type V using keys of type K such that if a
reference to a key no longer exists outside the map, the key/object pair is discarded. This contrasts
with HashMap<> where the presence of the key in the map maintains the life of the key/object pair,
even though the program using the map no longer has a reference to the key and therefore cannot
retrieve the object.
IdentityHashMap<K,V> : Implements a map storing values of type V using keys of type K using a
hash table where comparisons in searching the map for a key or a value compares references, not
objects. This implies that two keys are equal only if they are the same key. The same applies to
values. This is a specialized collection class for situations where reference equality is required for
both keys and objects.
TreeMap<K,V> : Implements a map storing values of type V using keys of type K such that the ob-
jects are arranged in ascending key order.
This is not an exhaustive list; it is just the classes that are most commonly used. In addition, the
java.util.concurrent package defines further collection classes that are specifically designed to support
concurrent operations by multiple threads.
The generic types representing sets, lists, and queues are related in the manner shown in Figure 14-5 .
FIGURE 14-5
The shaded boxes identify generic types that you use to define collections. The others are abstract types
that you cannot instantiate. All types that define sequences share a common base class, AbstractCollec-
tion<T> . This class defines methods for the operations that are common to sets, lists, and queues. The op-
erations provided by the AbstractCollection<T> class include adding objects to a collection, removing
objects, providing an iterator for a collection, and testing for the presence of one or more objects in a collec-
tion.
The parameterized types that define maps of various kinds are related as shown in Figure 14-6 .
FIGURE 14-6
 
 
 
 
Search WWH ::




Custom Search