Java Reference
In-Depth Information
Class
Representation
Since
null
keys
null
values
Notes
Hashtable plus list
1.4
Yes
Yes
Preserves insertion or access order.
LinkedHash
Map
Red-black tree
1.2
No
Yes
Sorts by key value. Operations are
O(log(n)). See SortedMap interface.
TreeMap
Hashtable
1.4
Yes
Yes
Compares with == instead of equals() .
Identity
HashMap
Hashtable
1.2
Yes
Yes
Doesn't prevent garbage collection of
keys.
WeakHash
Map
Hashtable
1.0
No
No
Legacy class; synchronized methods. Do
not use.
Hashtable
Hashtable
1.0
No
No
Extends Hashtable with String
methods.
Properties
The ConcurrentHashMap and ConcurrentSkipListMap classes of the java.util.con
current package implement the ConcurrentMap interface of the same package. Con
currentMap extends Map and defines some additional atomic operations that are
important in multithreaded programming. For example, the putIfAbsent method
is like put() but adds the key/value pair to the map only if the key is not already
mapped.
TreeMap implements the SortedMap interface, which extends Map to add methods
that take advantage of the sorted nature of the map. SortedMap is quite similar to
the SortedSet interface. The firstKey() and lastKey() methods return the first
and last keys in the keySet() . And headMap() , tailMap() , and subMap() return a
restricted range of the original map.
The Queue and BlockingQueue Interfaces
A queue is an ordered collection of elements with methods for extracting elements,
in order, from the head of the queue. Queue implementations are commonly based
on insertion order as in first-in, first-out (FIFO) queues or last-in, first-out (LIFO)
queues.
LIFO queues are also known as stacks, and Java provides a
Stack class, but its use is strongly discouraged—instead
implementations of the Deque interface should be used.
 
Search WWH ::




Custom Search