java.util
public
interface
java.util.Map<K, V>
Map has a set of keys, each key is mapped to a single value.
Nested Classes
Map.Entry<K, V> |
Map.Entry is a key/value mapping which is contained in a Map. |
Known Indirect Subclasses
AbstractMap<K, V>,
Attributes,
AuthProvider,
ConcurrentHashMap<K, V>,
ConcurrentMap<K, V>,
EnumMap<K extends
Enum<K>, V>,
HashMap<K, V>,
Hashtable<K, V>,
IdentityHashMap<K, V>,
LinkedHashMap<K, V>,
Properties,
Provider,
SortedMap<K, V>,
TreeMap<K, V>,
WeakHashMap<K, V>
AbstractMap<K, V> |
AbstractMap is an abstract implementation of the Map interface. |
Attributes |
The Attributes class is used to store values for Manifest entries. |
AuthProvider |
|
ConcurrentHashMap<K, V> |
A hash table supporting full concurrency of retrievals and
adjustable expected concurrency for updates. |
ConcurrentMap<K, V> |
A Map providing additional atomic
putIfAbsent, remove, and replace methods. |
EnumMap<K extends Enum<K>, V> |
|
HashMap<K, V> |
HashMap is an implementation of Map. |
Hashtable<K, V> |
Hashtable associates keys with values. |
IdentityHashMap<K, V> |
IdentityHashMap
This is a variant on HashMap which tests equality by reference instead of by
value. |
LinkedHashMap<K, V> |
LinkedHashMap is a variant on HashMap. |
Properties |
Properties is a Hashtable where the keys and values must be Strings. |
Provider |
|
SortedMap<K, V> |
SortedMap is a Map where the iterators sequence in order of the sorted keys. |
TreeMap<K, V> |
TreeMap is an implementation of SortedMap. |
WeakHashMap<K, V> |
WeakHashMap is an implementation of Map with keys which are WeakReferences. |
Summary
Details
Public Methods
public
void
clear()
Removes all elements from this Map, leaving it empty.
public
boolean
containsKey(Object key)
Searches this Map for the specified key.
Parameters
key
| the object to search for |
Returns
- true if
key
is a key of this Map, false otherwise
public
boolean
containsValue(Object value)
Searches this Map for the specified value.
Parameters
value
| the object to search for |
Returns
- true if
value
is a value of this Map, false
otherwise
public
Set<Entry<K, V>>
entrySet()
Returns a
Set
whose elements comprise all of the mappings
that are to be found in this
Map
. Information on each of
the mappings is encapsulated in a separate
Map.Entry instance. As
the
Set
is backed by this
Map
, users
should be aware that changes in one will be immediately visible in the
other.
public
boolean
equals(Object object)
Compares the argument to the receiver, and returns true if they represent
the
same object using a class specific comparison.
Parameters
object
| Object the object to compare with this object. |
Returns
- boolean
true
if the object is the same as this
object false
if it is different from this object.
public
V
get(Object key)
Returns the value of the mapping with the specified key.
Returns
- the value of the mapping with the specified key
public
int
hashCode()
Returns an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
public
boolean
isEmpty()
Returns if this Map has no elements, a size of zero.
Returns
- true if this Map has no elements, false otherwise
public
Set<K>
keySet()
Returns a Set of the keys contained in this Map. The set is backed by
this Map so changes to one are relected by the other. The set does not
support adding.
public
V
put(K key, V value)
Maps the specified key to the specified value.
Parameters
key
| the key |
value
| the value |
Returns
- the value of any previous mapping with the specified key or null
if there was no mapping
public
void
putAll(Map<? extends K, ? extends V> map)
Copies every mapping in the specified Map to this Map.
Parameters
map
| the Map to copy mappings from |
public
V
remove(Object key)
Removes a mapping with the specified key from this Map.
Parameters
key
| the key of the mapping to remove |
Returns
- the value of the removed mapping or null if key is not a key in
this Map
public
int
size()
Returns the number of elements in this Map.
Returns
- the number of elements in this Map
Returns all of the current
Map
values in a
Collection
. As the returned
Collection
is
backed by this
Map
, users should be aware that changes in
one will be immediately visible in the other.
Returns
- a Collection of the values