java.util.EnumMap<K extends java.lang.Enum<K>, V>
Summary
Public Constructors
Public Methods
clear,
clone,
containsKey,
containsValue,
entrySet,
equals,
get,
hashCode,
isEmpty,
keySet,
put,
putAll,
remove,
size,
toString,
values
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Methods inherited
from interface
java.util.Map
clear,
containsKey,
containsValue,
entrySet,
equals,
get,
hashCode,
isEmpty,
keySet,
put,
putAll,
remove,
size,
values
Details
Public Constructors
public
EnumMap(Class<K> keyType)
Constructs an empty enum map using the given key type.
Parameters
keyType
| the class object of the key type used by this enum map |
public
EnumMap(EnumMap<K, ? extends V> map)
Constructs an enum map using the same key type as the given enum map and
initially containing the same mappings.
Parameters
map
| the enum map from which this enum map is initialized |
public
EnumMap(Map<K, ? extends V> map)
Constructs an enum map initialized from the given map. If the given map
is an EnumMap instance, this constructor behaves in the exactly the same
way as
EnumMap(EnumMap)}. Otherwise, the given map at
least should contain one mapping.
Parameters
map
| the map from which this enum map is initialized |
Public Methods
public
void
clear()
Removes all mappings in this map.
public
EnumMap<K, V>
clone()
Returns a shallow copy of this map.
Returns
- a shallow copy of this map
public
boolean
containsKey(Object key)
Returns true if this map has a mapping for the given key.
Parameters
key
| the key whose presence in this map is to be tested |
Returns
- true if this map has a mapping for the given key.
public
boolean
containsValue(Object value)
Returns true if this map has one or more keys mapped to the given value.
Parameters
value
| the value whose presence in this map is to be tested |
Returns
- true if this map has one or more keys mapped to the given value.
public
Set<Entry<K, V>>
entrySet()
Returns a
Set} view of the mappings contained in this map. The
returned set complies with the general rule specified in
entrySet()}. The set's iterator will return the mappings in
the their keys' natural order(the enum constants are declared in this
order)
Returns
- a set view of the mappings contained in this map.
public
boolean
equals(Object object)
Compares the given object with this map. Returns true if the given object
is equal to this map.
Parameters
object
| the object to be compared with this map |
Returns
- true if the given object is equal to this map.
public
V
get(Object key)
Returns the value which is mapped to the given key in this map, or null
if this map has no mapping for the given key.
Parameters
key
| the key whose associated value is to be returned |
Returns
- the value to which this map maps the given key, or null if this
map has no mapping for the given key.
public
Set<K>
keySet()
Returns a
Set} view of the keys contained in this map. The
returned set complies with the general rule specified in
keySet()}. The set's iterator will return the keys in the
their natural order(the enum constants are declared in this order)
Returns
- a set view of the keys contained in this map.
public
V
put(K key, V value)
Associates the given value with the given key in this map. If the map
previously had a mapping for this key, the old value is replaced.
Parameters
key
| the key with which the given value is to be associated value |
value
| the value to be associated with the given key |
Returns
- the value to which this map maps the given key, or null if this
map has no mapping for the given key.
public
void
putAll(Map<? extends K, ? extends V> map)
Copies all the mappings in the given map to this map. These mappings will
replace all mappings that this map had for all of the keys currently in
the given map.
Parameters
map
| the key whose presence in this map is to be tested |
public
V
remove(Object key)
Removes the mapping for this key from this map if it is present.
Parameters
key
| the key whose mapping is to be removed from this map |
Returns
- the previous value associated with the given key, or null if this
map has no mapping for this key.
public
int
size()
Returns the number of the mappings in this map.
Returns
- the number of the mappings in this map
Returns a
Collection} view of the values contained in this map.
The returned collection complys with the general rule specified in
values()}. The collection's iterator will return the values
in the their corresponding keys' natural order(the enum constants are
declared in this order)
Returns
- a collection view of the mappings contained in this map.