|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractMap java.util.Collections.EmptyMap
Nested Class Summary |
Nested classes inherited from class java.util.AbstractMap |
AbstractMap.SimpleEntry |
Nested classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
private static long |
serialVersionUID
|
Fields inherited from class java.util.AbstractMap |
keySet, values |
Constructor Summary | |
private |
Collections.EmptyMap()
|
Method Summary | |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to this value. |
Set |
entrySet()
Returns a set view of the mappings contained in this map. |
boolean |
equals(Object o)
Compares the specified object with this map for equality. |
Object |
get(Object key)
Returns the value to which this map maps the specified key. |
int |
hashCode()
Returns the hash code value for this map. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
Set |
keySet()
Returns a Set view of the keys contained in this map. |
private Object |
readResolve()
|
int |
size()
Returns the number of key-value mappings in this map. |
Collection |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.util.AbstractMap |
clear, clone, put, putAll, remove, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final long serialVersionUID
Constructor Detail |
private Collections.EmptyMap()
Method Detail |
public int size()
AbstractMap
This implementation returns entrySet().size().
size
in interface Map
size
in class AbstractMap
public boolean isEmpty()
AbstractMap
This implementation returns size() == 0.
isEmpty
in interface Map
isEmpty
in class AbstractMap
public boolean containsKey(Object key)
AbstractMap
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, true is returned. If the iteration terminates without finding such an entry, false is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.
containsKey
in interface Map
containsKey
in class AbstractMap
key
- key whose presence in this map is to be tested.
public boolean containsValue(Object value)
AbstractMap
This implementation iterates over entrySet() searching for an entry with the specified value. If such an entry is found, true is returned. If the iteration terminates without finding such an entry, false is returned. Note that this implementation requires linear time in the size of the map.
containsValue
in interface Map
containsValue
in class AbstractMap
value
- value whose presence in this map is to be tested.
public Object get(Object key)
AbstractMap
This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, the entry's value is returned. If the iteration terminates without finding such an entry, null is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.
get
in interface Map
get
in class AbstractMap
key
- key whose associated value is to be returned.
AbstractMap.containsKey(Object)
public Set keySet()
AbstractMap
This implementation returns a Set that subclasses AbstractSet. The subclass's iterator method returns a "wrapper object" over this map's entrySet() iterator. The size method delegates to this map's size method and the contains method delegates to this map's containsKey method.
The Set is created the first time this method is called, and returned in response to all subsequent calls. No synchronization is performed, so there is a slight chance that multiple calls to this method will not all return the same Set.
keySet
in interface Map
keySet
in class AbstractMap
public Collection values()
AbstractMap
This implementation returns a collection that subclasses abstract collection. The subclass's iterator method returns a "wrapper object" over this map's entrySet() iterator. The size method delegates to this map's size method and the contains method delegates to this map's containsValue method.
The collection is created the first time this method is called, and returned in response to all subsequent calls. No synchronization is performed, so there is a slight chance that multiple calls to this method will not all return the same Collection.
values
in interface Map
values
in class AbstractMap
public Set entrySet()
AbstractMap
entrySet
in interface Map
entrySet
in class AbstractMap
public boolean equals(Object o)
AbstractMap
This implementation first checks if the specified object is this map; if so it returns true. Then, it checks if the specified object is a map whose size is identical to the size of this set; if not, it it returns false. If so, it iterates over this map's entrySet collection, and checks that the specified map contains each mapping that this map contains. If the specified map fails to contain such a mapping, false is returned. If the iteration completes, true is returned.
equals
in interface Map
equals
in class AbstractMap
o
- object to be compared for equality with this map.
public int hashCode()
AbstractMap
This implementation iterates over entrySet(), calling hashCode on each element (entry) in the Collection, and adding up the results.
hashCode
in interface Map
hashCode
in class AbstractMap
Map.Entry.hashCode()
,
Object.hashCode()
,
Object.equals(Object)
,
Set.equals(Object)
private Object readResolve()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |