Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 701
نمايش فراداده

EnumMap<K extends Enum<K>,V>java.util

Java 5.0cloneable serializable collection

This class is a Map implementation for use with enumerated types. The key type K must be an enumerated type, and all keys must be enumerated constants defined by that type. null keys are not permitted. The value type V is unrestricted and null values are permitted.

The EnumMap implementation is based on an array of elements of type V. The length of this array is the same as the number of constants defined by the enumerated type K. All Map operations execute in constant time. The iterators of the keySet( ), enTRySet( ), and values( ) collections iterate their elements in the ordinal order of the enumerated constants. EnumMap is not threadsafe, but its iterators are based on a snapshot of the underlying array and never throw ConcurrentModificationException.

Figure 16-16. java.util.EnumMap<K extends Enum<K>,V>

public class

EnumMap<K extends Enum<K>,V> extends AbstractMap<K,V> implements Serializable, Cloneable { // Public Constructors public

EnumMap (EnumMap<K,? extends V>

m ); public

EnumMap (Class<K>

keyType ); public

EnumMap (Map<K,? extends V>

m ); // Public Instance Methods public EnumMap<K,V>

clone ( ); public V

put (K

key , V

value ); // Public Methods Overriding AbstractMap public void

clear ( ); public boolean

containsKey (Object

key ); public boolean

containsValue (Object

value ); public Set<Map.Entry<K,V>>

entrySet ( ); public boolean

equals (Object

o ); public V

get (Object

key ); public Set<K>

keySet ( ); public void

putAll (Map<? extends K,? extends V>

m ); public V

remove (Object

key ); public int

size ( ); public Collection<V>

values ( ); }