Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » util » [javadoc | source]
java.util
public class: HashMap [javadoc | source]
java.lang.Object
   java.util.AbstractMap<K, V>
      java.util.HashMap

All Implemented Interfaces:
    Cloneable, Map, Serializable

Direct Known Subclasses:
    PrinterStateReasons, ResultStyleHashMap, LinkedHashMap, NegativeCache, ProcessEnvironment

HashMap is an implementation of Map. All optional operations (adding and removing) are supported. Keys and values can be any objects.
Nested Class Summary:
static class  HashMap.Entry   
static class  HashMap.HashMapEntrySet   
Field Summary
transient  int elementCount     
transient  Entry<K, V>[] elementData     
transient  int modCount     
final  float loadFactor     
 int threshold     
Fields inherited from java.util.AbstractMap:
keySet,  valuesCollection
Constructor:
 public HashMap() 
 public HashMap(int capacity) 
 public HashMap(Map<? extends K, ? extends V> map) 
    Constructs a new {@code HashMap} instance containing the mappings from the specified map.
    Parameters:
    map - the mappings to add.
 public HashMap(int capacity,
    float loadFactor) 
Method from java.util.HashMap Summary:
areEqualKeys,   areEqualValues,   clear,   clone,   computeHashCode,   containsKey,   containsValue,   createEntry,   createHashedEntry,   entrySet,   findNonNullKeyEntry,   findNullKeyEntry,   get,   getEntry,   isEmpty,   keySet,   newElementArray,   put,   putAll,   putImpl,   rehash,   rehash,   remove,   removeEntry,   removeEntry,   size,   values
Methods from java.util.AbstractMap:
clear,   clone,   containsKey,   containsValue,   entrySet,   equals,   get,   hashCode,   isEmpty,   keySet,   put,   putAll,   remove,   size,   toString,   values
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.HashMap Detail:
 static boolean areEqualKeys(Object key1,
    Object key2) 
 static boolean areEqualValues(Object value1,
    Object value2) 
 public  void clear() 
    Removes all mappings from this hash map, leaving it empty.
 public Object clone() 
    Returns a shallow copy of this map.
 static int computeHashCode(Object key) 
 public boolean containsKey(Object key) 
    Returns whether this map contains the specified key.
 public boolean containsValue(Object value) 
    Returns whether this map contains the specified value.
 Entry<K, V> createEntry(K key,
    int index,
    V value) 
 Entry<K, V> createHashedEntry(K key,
    int index,
    int hash) 
 public Set<K, V> entrySet() 
    Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry . As the set is backed by this map, changes in one will be reflected in the other.
 final Entry<K, V> findNonNullKeyEntry(Object key,
    int index,
    int keyHash) 
 final Entry<K, V> findNullKeyEntry() 
 public V get(Object key) 
    Returns the value of the mapping with the specified key.
 final Entry<K, V> getEntry(Object key) 
 public boolean isEmpty() 
    Returns whether this map is empty.
 public Set<K> keySet() 
    Returns a set of the keys contained in this map. The set is backed by this map so changes to one are reflected by the other. The set does not support adding.
 Entry<K, V>[] newElementArray(int s) 
    Create a new element array
 public V put(K key,
    V value) 
    Maps the specified key to the specified value.
 public  void putAll(Map<? extends K, ? extends V> map) 
    Copies all the mappings in the specified map to this map. These mappings will replace all mappings that this map had for any of the keys currently in the given map.
 V putImpl(K key,
    V value) 
  void rehash() 
  void rehash(int capacity) 
 public V remove(Object key) 
    Removes the mapping with the specified key from this map.
 final  void removeEntry(Entry<K, V> entry) 
 final Entry<K, V> removeEntry(Object key) 
 public int size() 
    Returns the number of elements in this map.
 public Collection<V> values() 
    Returns a collection of the values contained in this map. The collection is backed by this map so changes to one are reflected by the other. The collection supports remove, removeAll, retainAll and clear operations, and it does not support add or addAll operations.

    This method returns a collection which is the subclass of AbstractCollection. The iterator method of this subclass returns a "wrapper object" over the iterator of map's entrySet(). The {@code size} method wraps the map's size method and the {@code contains} method wraps the map's containsValue method.

    The collection is created when this method is called for the first time and returned in response to all subsequent calls. This method may return different collections when multiple concurrent calls occur, since no synchronization is performed.