|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.EnumMap<K,V>
public class EnumMap<K extends Enum<K>,V>
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
EnumMap(Class<K> keyType)
|
|
EnumMap(EnumMap<K,? extends V> map)
|
|
EnumMap(Map<K,? extends V> map)
|
|
| Method Summary | |
|---|---|
void |
clear()
Remove all entries from this Map (optional operation). |
EnumMap<K,V> |
clone()
Create a shallow copy of this Map, no keys or values are copied. |
boolean |
containsKey(Object key)
Returns true if this contains a mapping for the given key. |
boolean |
containsValue(Object value)
Returns true if this contains at least one mapping with the given value. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings in this Map. |
boolean |
equals(Object o)
Compares the specified object with this map for equality. |
V |
get(Object key)
Returns the value mapped by the given key. |
Set<K> |
keySet()
Returns a set view of this map's keys. |
V |
put(K key,
V value)
Associates the given key to the given value (optional operation). |
void |
putAll(Map<? extends K,? extends V> map)
Copies all entries of the given map to this one (optional operation). |
V |
remove(Object key)
Removes the mapping for this key if present (optional operation). |
int |
size()
Returns the number of key-value mappings in the map. |
Collection<V> |
values()
Returns a collection or bag view of this map's values. |
| Methods inherited from class java.util.AbstractMap |
|---|
hashCode, isEmpty, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public EnumMap(Class<K> keyType)
public EnumMap(EnumMap<K,? extends V> map)
public EnumMap(Map<K,? extends V> map)
| Method Detail |
|---|
public int size()
AbstractMapentrySet().size().
size in interface Map<K extends Enum<K>,V>size in class AbstractMap<K extends Enum<K>,V>Set.size()public boolean containsValue(Object value)
AbstractMapentrySet(), returning true if a match
is found, false if the iteration ends. A match is
defined as a value, v, where (value == null ? v == null :
value.equals(v)). Subclasses are unlikely to implement
this more efficiently.
containsValue in interface Map<K extends Enum<K>,V>containsValue in class AbstractMap<K extends Enum<K>,V>value - the value to search for
AbstractMap.containsKey(Object)public boolean containsKey(Object key)
AbstractMapentrySet(), returning true if a match
is found, false if the iteration ends. Many subclasses
can implement this more efficiently.
containsKey in interface Map<K extends Enum<K>,V>containsKey in class AbstractMap<K extends Enum<K>,V>key - the key to search for
AbstractMap.containsValue(Object)public V get(Object key)
AbstractMapnull if
there is no mapping. However, in Maps that accept null values, you
must rely on containsKey to determine if a mapping exists.
This iteration takes linear time, searching entrySet().iterator() of
the key. Many implementations override this method.
get in interface Map<K extends Enum<K>,V>get in class AbstractMap<K extends Enum<K>,V>key - the key to look up
AbstractMap.containsKey(Object)
public V put(K key,
V value)
AbstractMapnull values, a null return does not always
imply that the mapping was created.
put in interface Map<K extends Enum<K>,V>put in class AbstractMap<K extends Enum<K>,V>key - the key to mapvalue - the value to be mapped
AbstractMap.containsKey(Object)public V remove(Object key)
AbstractMapremove method.
It returns the result of getValue() on the entry, if found,
or null if no entry is found. Note that maps which permit null values
may also return null if the key was removed. If the entrySet does not
support removal, this will also fail. This is O(n), so many
implementations override it for efficiency.
remove in interface Map<K extends Enum<K>,V>remove in class AbstractMap<K extends Enum<K>,V>key - the key to remove
Iterator.remove()public void putAll(Map<? extends K,? extends V> map)
AbstractMapput,
so it is not supported if puts are not.
putAll in interface Map<K extends Enum<K>,V>putAll in class AbstractMap<K extends Enum<K>,V>map - the mapping to load into this mapAbstractMap.put(Object, Object)public void clear()
AbstractMapAbstractMap.clear unless you want an infinite loop.
clear in interface Map<K extends Enum<K>,V>clear in class AbstractMap<K extends Enum<K>,V>Set.clear()public Set<K> keySet()
AbstractMapThis implementation creates an AbstractSet, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsKey. The set is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two sets.
keySet in interface Map<K extends Enum<K>,V>keySet in class AbstractMap<K extends Enum<K>,V>Set.iterator(),
AbstractMap.size(),
AbstractMap.containsKey(Object),
AbstractMap.values()public Collection<V> values()
AbstractMapThis implementation creates an AbstractCollection, where the iterator wraps the entrySet iterator, size defers to the Map's size, and contains defers to the Map's containsValue. The collection is created on first use, and returned on subsequent uses, although since no synchronization occurs, there is a slight possibility of creating two collections.
values in interface Map<K extends Enum<K>,V>values in class AbstractMap<K extends Enum<K>,V>Collection.iterator(),
AbstractMap.size(),
AbstractMap.containsValue(Object),
AbstractMap.keySet()public Set<Map.Entry<K,V>> entrySet()
AbstractMapIterator.remove, Set.remove,
removeAll, retainAll, and clear.
Element addition is not supported via this set.
entrySet in interface Map<K extends Enum<K>,V>entrySet in class AbstractMap<K extends Enum<K>,V>Map.Entrypublic boolean equals(Object o)
AbstractMaptrue if the other object is a Map with the same mappings,
that is,o instanceof Map && entrySet().equals(((Map) o).entrySet();
equals in interface Map<K extends Enum<K>,V>equals in class AbstractMap<K extends Enum<K>,V>o - the object to be compared
Set.equals(Object)public EnumMap<K,V> clone()
AbstractMapsuper.clone().
clone in class AbstractMap<K extends Enum<K>,V>Cloneable,
Object.clone()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||