|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractMap | +--java.util.HashMap
Untamed:
Field Summary | |
(package private) static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity - MUST be a power of two. |
(package private) static float |
DEFAULT_LOAD_FACTOR
The load fast used when none specified in constructor. |
private Set |
entrySet
|
(package private) float |
loadFactor
The load factor for the hash table. |
(package private) static int |
MAXIMUM_CAPACITY
The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments. |
(package private) 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). |
(package private) static Object |
NULL_KEY
Value representing null keys inside tables. |
private static long |
serialVersionUID
|
(package private) int |
size
The number of key-value mappings contained in this identity hash map. |
(package private) java.util.HashMap.Entry[] |
table
The table, resized as necessary. |
(package private) int |
threshold
The next size value at which to resize (capacity * load factor). |
Fields inherited from class java.util.AbstractMap |
keySet, values |
Constructor Summary | |
HashMap()
Enabled: Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75). |
|
HashMap(int initialCapacity)
Enabled: Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75). |
|
HashMap(int initialCapacity,
float loadFactor)
Enabled: Constructs an empty HashMap with the specified initial capacity and load factor. |
|
HashMap(Map m)
Enabled: Constructs a new HashMap with the same mappings as the specified Map. |
Method Summary | |
(package private) void |
addEntry(int hash,
Object key,
Object value,
int bucketIndex)
Add a new entry with the specified key, value and hash code to the specified bucket. |
(package private) int |
capacity()
|
void |
clear()
Enabled: Removes all mappings from this map. |
Object |
clone()
Suppressed: Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned. |
boolean |
containsKey(Object key)
Enabled: Returns true if this map contains a mapping for the specified key. |
private boolean |
containsNullValue()
Special-case code for containsValue with null argument |
boolean |
containsValue(Object value)
Enabled: Returns true if this map maps one or more keys to the specified value. |
(package private) void |
createEntry(int hash,
Object key,
Object value,
int bucketIndex)
Like addEntry except that this version is used when creating entries as part of Map construction or "pseudo-construction" (cloning, deserialization). |
Set |
entrySet()
Enabled: Returns a collection view of the mappings contained in this map. |
(package private) static boolean |
eq(Object x,
Object y)
Check for equality of non-null reference x and possibly-null y. |
Object |
get(Object key)
Enabled: Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. |
(package private) java.util.HashMap.Entry |
getEntry(Object key)
Returns the entry associated with the specified key in the HashMap. |
(package private) static int |
hash(Object x)
Returns a hash value for the specified object. |
(package private) static int |
indexFor(int h,
int length)
Returns index for hash code h. |
(package private) void |
init()
Initialization hook for subclasses. |
boolean |
isEmpty()
Enabled: Returns true if this map contains no key-value mappings. |
Set |
keySet()
Enabled: Returns a set view of the keys contained in this map. |
(package private) float |
loadFactor()
|
(package private) static Object |
maskNull(Object key)
Returns internal representation for key. |
(package private) Iterator |
newEntryIterator()
|
(package private) Iterator |
newKeyIterator()
|
(package private) Iterator |
newValueIterator()
|
Object |
put(Object key,
Object value)
Enabled: Associates the specified value with the specified key in this map. |
void |
putAll(Map t)
Enabled: Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map. |
(package private) void |
putAllForCreate(Map m)
|
private void |
putForCreate(Object key,
Object value)
This method is used instead of put by constructors and pseudoconstructors (clone, readObject). |
private void |
readObject(ObjectInputStream s)
Reconstitute the HashMap instance from a stream (i.e., deserialize it). |
Object |
remove(Object key)
Enabled: Removes the mapping for this key from this map if present. |
(package private) java.util.HashMap.Entry |
removeEntryForKey(Object key)
Removes and returns the entry associated with the specified key in the HashMap. |
(package private) java.util.HashMap.Entry |
removeMapping(Object o)
Special version of remove for EntrySet. |
(package private) void |
resize(int newCapacity)
Rehashes the contents of this map into a new HashMap instance with a larger capacity. |
int |
size()
Enabled: Returns the number of key-value mappings in this map. |
(package private) void |
transfer(java.util.HashMap.Entry[] newTable)
Transfer all entries from current table to newTable. |
(package private) static Object |
unmaskNull(Object key)
Returns key represented by specified internal representation. |
Collection |
values()
Enabled: Returns a collection view of the values contained in this map. |
private void |
writeObject(ObjectOutputStream s)
Save the state of the HashMap instance to a stream (i.e., serialize it). |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Field Detail |
static final int DEFAULT_INITIAL_CAPACITY
static final int MAXIMUM_CAPACITY
static final float DEFAULT_LOAD_FACTOR
transient java.util.HashMap.Entry[] table
transient int size
int threshold
final float loadFactor
transient volatile int modCount
static final Object NULL_KEY
private transient Set entrySet
private static final long serialVersionUID
Constructor Detail |
public HashMap(int initialCapacity, float loadFactor)
initialCapacity
- The initial capacity.loadFactor
- The load factor.
IllegalArgumentException
- if the initial capacity is negative
or the load factor is nonpositive.public HashMap(int initialCapacity)
initialCapacity
- the initial capacity.
IllegalArgumentException
- if the initial capacity is negative.public HashMap()
public HashMap(Map m)
m
- the map whose mappings are to be placed in this map.
NullPointerException
- if the specified map is null.Method Detail |
void init()
static Object maskNull(Object key)
static Object unmaskNull(Object key)
static int hash(Object x)
The shift distances in this function were chosen as the result of an automated search over the entire four-dimensional search space.
static boolean eq(Object x, Object y)
static int indexFor(int h, int length)
public int size()
size
in interface Map
size
in class AbstractMap
public boolean isEmpty()
isEmpty
in interface Map
isEmpty
in class AbstractMap
public Object get(Object key)
get
in interface Map
get
in class AbstractMap
key
- the key whose associated value is to be returned.
put(Object, Object)
public boolean containsKey(Object key)
containsKey
in interface Map
containsKey
in class AbstractMap
key
- The key whose presence in this map is to be tested
java.util.HashMap.Entry getEntry(Object key)
public Object put(Object key, Object value)
put
in interface Map
put
in class AbstractMap
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
private void putForCreate(Object key, Object value)
void putAllForCreate(Map m)
void resize(int newCapacity)
newCapacity
- the new capacity, MUST be a power of two.void transfer(java.util.HashMap.Entry[] newTable)
public void putAll(Map t)
putAll
in interface Map
putAll
in class AbstractMap
t
- mappings to be stored in this map.
NullPointerException
- if the specified map is null.public Object remove(Object key)
remove
in interface Map
remove
in class AbstractMap
key
- key whose mapping is to be removed from the map.
java.util.HashMap.Entry removeEntryForKey(Object key)
java.util.HashMap.Entry removeMapping(Object o)
public void clear()
clear
in interface Map
clear
in class AbstractMap
public boolean containsValue(Object value)
containsValue
in interface Map
containsValue
in class AbstractMap
value
- value whose presence in this map is to be tested.
private boolean containsNullValue()
public Object clone()
clone
in class AbstractMap
void addEntry(int hash, Object key, Object value, int bucketIndex)
void createEntry(int hash, Object key, Object value, int bucketIndex)
Iterator newKeyIterator()
Iterator newValueIterator()
Iterator newEntryIterator()
public Set keySet()
keySet
in interface Map
keySet
in class AbstractMap
public Collection values()
values
in interface Map
values
in class AbstractMap
public Set entrySet()
entrySet
in interface Map
entrySet
in class AbstractMap
Map.Entry
private void writeObject(ObjectOutputStream s) throws IOException
IOException
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
int capacity()
float loadFactor()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |