Map
interface, to minimize the effort required to implement this interface.
To implement an unmodifiable map, the programmer needs only to extend this
class and provide an implementation for the entrySet method, which
returns a set-view of the map's mappings. Typically, the returned set
will, in turn, be implemented atop AbstractSet. This set should
not support the add or remove methods, and its iterator
should not support the remove method.
To implement a modifiable map, the programmer must additionally override
this class's put method (which otherwise throws an
UnsupportedOperationException), and the iterator returned by
entrySet().iterator() must additionally implement its
remove method.
The programmer should generally provide a void (no argument) and map
constructor, as per the recommendation in the Map interface
specification.
The documentation for each non-abstract method in this class describes its implementation in detail. Each of these methods may be overridden if the map being implemented admits a more efficient implementation.
This class is a member of the Java Collections Framework.
Map, Collection
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | |
| public static class | AbstractMap.
the type of key K, the type of the value V>An Entry maintaining a key and a value. |
| public static class | AbstractMap.
the type of the keys K, the type of the value V>An unmodifiable Entry maintaining a key and a value. |
| pack-priv class | |
| pack-priv abstract static class | AbstractMap.
the view's element type E>Delegates all Collection methods to the provided non-sequenced map view, except add() and addAll(), which throw UOE. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv transient Set | keySet
Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested. |
| pack-priv transient Collection |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements java. Removes all of the mappings from this map (optional operation). |
| protected Object | Returns: a shallow copy of this mapOverrides java. Returns a shallow copy of this |
| public boolean | containsKey(Object key)
Implements java. Returns |
| public boolean | containsValue(Object value)
Implements java. Returns |
| public abstract Set | entrySet()
Redeclares java. Returns a |
| private static boolean | |
| public boolean | Returns: true if the specified object is equal to this mapobject to be compared for equality with this map o)Overrides java. Implements java. Compares the specified object with this map for equality. |
| public V | get(Object key)
Implements java. Returns the value to which the specified key is mapped,
or |
| public int | Returns: the hash code value for this mapOverrides java. Implements java. Returns the hash code value for this map. |
| public boolean | |
| public Set | |
| public V | put(K key, V value)
Implements java. Associates the specified value with the specified key in this map (optional operation). |
| public void | putAll(Map<? extends K, ? extends V> m)
Implements java. Copies all of the mappings from the specified map to this map (optional operation). |
| public V | remove(Object key)
Implements java. Removes the mapping for a key from this map if it is present (optional operation). |
| public int | |
| public String | Returns: a string representation of this mapOverrides java. Returns a string representation of this map. |
| public Collection | values()
Implements java. Returns a |