API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util. HashMap View Source
Author(s)
Doug Lea
Josh Bloch
Arthur van Hoff
Neal Gafter
Since
1.2
Version
1.73, 03/13/07
Serial
Hierarchy
 Object
      AbstractMap
          HashMap
Implements
 Map
 Cloneable
 Serializable
Subclasses
Description
public class HashMap
  Hash table based implementation of the Map interface.
Constructors
public HashMap ()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).
public HashMap (int initialCapacity)
  Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).
public HashMap (int initialCapacity, float loadFactor)
  Constructs an empty HashMap with the specified initial capacity and load factor.
public HashMap (Map<Object, Object> m)
  Constructs a new HashMap with the same mappings as the specified Map.
Methods
Hide/Show inherited methods
pack-private void addEntry (int hash, K key, V value, int bucketIndex)
  Adds a new entry with the specified key, value and hash code to the specified bucket.
pack-private int capacity ()
public void clear () [Overrides AbstractMap] [Specified in Map]
  Removes all of the mappings from this map.
public Object clone () [Overrides AbstractMap]
  Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
public boolean containsKey (Object key) [Overrides AbstractMap] [Specified in Map]
  Returns true if this map contains a mapping for the specified key.
public boolean containsValue (Object value) [Overrides AbstractMap] [Specified in Map]
  Returns true if this map maps one or more keys to the specified value.
pack-private void createEntry (int hash, K key, V value, int bucketIndex)
  Like addEntry except that this version is used when creating entries as part of Map construction or "pseudo-construction" (cloning, deserialization).
public Set<Entry< K, V>> entrySet () [Specified in Map]
  Returns a Set view of the mappings contained in this map.
public boolean equals (Object o) [Inherited From AbstractMap]
  Compares the specified object with this map for equality.
public V get (Object key) [Overrides AbstractMap] [Specified in Map]
  Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
pack-privatefinal Entry< K, V> getEntry (Object key)
  Returns the entry associated with the specified key in the HashMap.
pack-privatestatic int hash (int h)
  Applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions.
public int hashCode () [Inherited From AbstractMap]
  Returns the hash code value for this map.
pack-privatestatic int indexFor (int h, int length)
Returns index for hash code h.
pack-private void init ()
  Initialization hook for subclasses.
public boolean isEmpty () [Overrides AbstractMap] [Specified in Map]
  Returns true if this map contains no key-value mappings.
public Set< K> keySet () [Overrides AbstractMap] [Specified in Map]
  Returns a Set view of the keys contained in this map.
pack-private float loadFactor ()
pack-private Iterator<Entry< K, V>> newEntryIterator ()
pack-private Iterator< K> newKeyIterator ()
pack-private Iterator< V> newValueIterator ()
public V put ( K key, V value) [Overrides AbstractMap] [Specified in Map]
  Associates the specified value with the specified key in this map.
public void putAll (Map<Object, Object> m) [Overrides AbstractMap] [Specified in Map]
  Copies all of the mappings from the specified map to this map.
public V remove (Object key) [Overrides AbstractMap] [Specified in Map]
  Removes the mapping for the specified key from this map if present.
pack-privatefinal Entry< K, V> removeEntryForKey (Object key)
  Removes and returns the entry associated with the specified key in the HashMap.
pack-privatefinal Entry< K, V> removeMapping (Object o)
Special version of remove for EntrySet.
pack-private void resize (int newCapacity)
  Rehashes the contents of this map into a new array with a larger capacity.
public int size () [Overrides AbstractMap] [Specified in Map]
  Returns the number of key-value mappings in this map.
public String toString () [Inherited From AbstractMap]
  Returns a string representation of this map.
pack-private void transfer (Entry newTable)
Transfers all entries from current table to newTable.
public Collection< V> values () [Overrides AbstractMap] [Specified in Map]
  Returns a Collection view of the values contained in this map.
Fields
Hide/Show inherited fields
pack-privatefinalstatic int DEFAULT_INITIAL_CAPACITY = "16"
The default initial capacity - MUST be a power of two.
pack-privatefinalstatic float DEFAULT_LOAD_FACTOR = "0.75"
The load factor used when none specified in constructor.
pack-privatetransientvolatile Set< K> keySet [Inherited From AbstractMap]
  Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested.
pack-privatefinal float loadFactor
The load factor for the hash table.
pack-privatefinalstatic int MAXIMUM_CAPACITY = "1073741824"
  The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments.
pack-privatetransientvolatile int modCount
  The number of times this HashMap has been structurally modified Structural modifications are those that change the number of mappings in the HashMap or otherwise modify its internal structure (e.g., rehash).
pack-privatetransient int size
The number of key-value mappings contained in this map.
pack-privatetransient Entry table
  The table, resized as necessary.
pack-private int threshold
The next size value at which to resize (capacity * load factor).
pack-privatetransientvolatile Collection< V> values [Inherited From AbstractMap]
Nested Classes
  HashMap.Entry
  AbstractMap.SimpleEntry
An Entry maintaining a key and a value.
  AbstractMap.SimpleImmutableEntry
An Entry maintaining an immutable key and value.
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar