Top Description Inners Fields Constructors Methods
sun.jvm.hotspot.debugger

public Class LongHashMap

extends Object
Class Inheritance
Imports
java.util.*

This is a copy of java.util.HashMap which uses longs as keys instead of Objects. It turns out that using this in the PageCache implementation speeds up heap traversals by a factor of three.
Authors
Josh Bloch, Arthur van Hoff

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final float
loadFactor

The load factor for the hash table.

pack-priv transient 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-priv transient int
size

The total number of mappings in the hash table.

pack-priv transient LongHashMap.Entry[]
table

The hash table data.

pack-priv int
threshold

The table is rehashed when its size exceeds this threshold.

Constructor Summary

AccessConstructor and Description
public
LongHashMap(int
the initial capacity of the HashMap.
initialCapacity
,
float
the load factor of the HashMap
loadFactor
)

Constructs a new, empty map with the specified initial capacity and the specified load factor.

public
LongHashMap(int
the initial capacity of the HashMap.
initialCapacity
)

Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.

public
LongHashMap()

Constructs a new, empty map with a default capacity and load factor, which is 0.75.

Method Summary

Modifier and TypeMethod and Description
pack-priv int
public void
clear()

Removes all mappings from this map.

public boolean

Returns:

true if this map contains a mapping for the specified key.
containsKey
(long
key whose presence in this Map is to be tested.
key
)

Returns true if this map contains a mapping for the specified key.

public boolean

Returns:

true if this map maps one or more keys to the specified value.
containsValue
(Object
value whose presence in this map is to be tested.
value
)

Returns true if this map maps one or more keys to the specified value.

pack-priv static boolean
eq(Object o1, Object o2)

public Object

Returns:

the value to which this map maps the specified key.
get
(long
key whose associated value is to be returned.
key
)

Returns the value to which this map maps the specified key.

pack-priv LongHashMap.Entry
getEntry(long key)

Returns the entry associated with the specified key in the HashMap.

public boolean

Returns:

true if this map contains no key-value mappings.
isEmpty
()

Returns true if this map contains no key-value mappings.

pack-priv float
pack-priv LongHashMap.Entry
newEntry(int hash, long key, Object value, LongHashMap.Entry next)

public Object

Returns:

previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.
put
(long
key with which the specified value is to be associated.
key
,
Object
value to be associated with the specified key.
value
)

Associates the specified value with the specified key in this map.

pack-priv void
rehash()

Rehashes the contents of this map into a new HashMap instance with a larger capacity.

public Object

Returns:

previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
remove
(long
key whose mapping is to be removed from the map.
key
)

Removes the mapping for this key from this map if present.

pack-priv void
removeEntry(LongHashMap.Entry doomed)

Removes the specified entry from this HashMap (and increments modCount).

pack-priv LongHashMap.Entry
removeEntryForKey(long key)

Removes and returns the entry associated with the specified key in the HashMap.

public int

Returns:

the number of key-value mappings in this map.
size
()

Returns the number of key-value mappings in this map.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loadFactorback to summary
pack-priv final float loadFactor

The load factor for the hash table.

modCountback to summary
pack-priv transient 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). This field is used to make iterators on Collection-views of the HashMap fail-fast. (See ConcurrentModificationException).

sizeback to summary
pack-priv transient int size

The total number of mappings in the hash table.

tableback to summary
pack-priv transient LongHashMap.Entry[] table

The hash table data.

thresholdback to summary
pack-priv int threshold

The table is rehashed when its size exceeds this threshold. (The value of this field is (int)(capacity * loadFactor).)

Constructor Detail

LongHashMapback to summary
public LongHashMap(int initialCapacity, float loadFactor)

Constructs a new, empty map with the specified initial capacity and the specified load factor.

Parameters
initialCapacity:int

the initial capacity of the HashMap.

loadFactor:float

the load factor of the HashMap

Exceptions
IllegalArgumentException:
if the initial capacity is less than zero, or if the load factor is nonpositive.
LongHashMapback to summary
public LongHashMap(int initialCapacity)

Constructs a new, empty map with the specified initial capacity and default load factor, which is 0.75.

Parameters
initialCapacity:int

the initial capacity of the HashMap.

Exceptions
IllegalArgumentException:
if the initial capacity is less than zero.
LongHashMapback to summary
public LongHashMap()

Constructs a new, empty map with a default capacity and load factor, which is 0.75.

Method Detail

capacityback to summary
pack-priv int capacity()
clearback to summary
public void clear()

Removes all mappings from this map.

containsKeyback to summary
public boolean containsKey(long key)

Returns true if this map contains a mapping for the specified key.

Parameters
key:long

key whose presence in this Map is to be tested.

Returns:boolean

true if this map contains a mapping for the specified key.

containsValueback to summary
public boolean containsValue(Object value)

Returns true if this map maps one or more keys to the specified value.

Parameters
value:Object

value whose presence in this map is to be tested.

Returns:boolean

true if this map maps one or more keys to the specified value.

eqback to summary
pack-priv static boolean eq(Object o1, Object o2)
getback to summary
public Object get(long key)

Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:long

key whose associated value is to be returned.

Returns:Object

the value to which this map maps the specified key.

getEntryback to summary
pack-priv LongHashMap.Entry getEntry(long key)

Returns the entry associated with the specified key in the HashMap. Returns null if the HashMap contains no mapping for this key.

isEmptyback to summary
public boolean isEmpty()

Returns true if this map contains no key-value mappings.

Returns:boolean

true if this map contains no key-value mappings.

loadFactorback to summary
pack-priv float loadFactor()
newEntryback to summary
pack-priv LongHashMap.Entry newEntry(int hash, long key, Object value, LongHashMap.Entry next)
putback to summary
public Object put(long key, Object value)

Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

Parameters
key:long

key with which the specified value is to be associated.

value:Object

value to be associated with the specified key.

Returns:Object

previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the HashMap previously associated null with the specified key.

rehashback to summary
pack-priv void rehash()

Rehashes the contents of this map into a new HashMap instance with a larger capacity. This method is called automatically when the number of keys in this map exceeds its capacity and load factor.

removeback to summary
public Object remove(long key)

Removes the mapping for this key from this map if present.

Parameters
key:long

key whose mapping is to be removed from the map.

Returns:Object

previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.

removeEntryback to summary
pack-priv void removeEntry(LongHashMap.Entry doomed)

Removes the specified entry from this HashMap (and increments modCount).

Exceptions
ConcurrentModificationException:
if the entry is not in the Map
removeEntryForKeyback to summary
pack-priv LongHashMap.Entry removeEntryForKey(long key)

Removes and returns the entry associated with the specified key in the HashMap. Returns null if the HashMap contains no mapping for this key.

sizeback to summary
public int size()

Returns the number of key-value mappings in this map.

Returns:int

the number of key-value mappings in this map.

sun.jvm.hotspot.debugger back to summary

pack-priv Class LongHashMap.Entry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private long
private LongHashMap.Entry
private Object

Constructor Summary

AccessConstructor and Description
pack-priv
Entry(int hash, long key, Object value, LongHashMap.Entry next)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the specified object is equal to this map entry.
equals
(Object
object to be compared for equality with this map entry.
o
)

Overrides java.lang.Object.equals.

Compares the specified object with this entry for equality.
pack-priv long

Returns:

the key corresponding to this entry.
getKey
()

Returns the key corresponding to this entry.

pack-priv Object

Returns:

the value corresponding to this entry.
getValue
()

Returns the value corresponding to this entry.

public int

Returns:

the hash code value for this map entry.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this map entry.
pack-priv Object

Returns:

old value corresponding to the entry.
setValue
(Object
new value to be stored in this entry.
value
)

Replaces the value corresponding to this entry with the specified value (optional operation).

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

hashback to summary
private int hash
keyback to summary
private long key
nextback to summary
private LongHashMap.Entry next
valueback to summary
private Object value

Constructor Detail

Entryback to summary
pack-priv Entry(int hash, long key, Object value, LongHashMap.Entry next)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping. More formally, two entries e1 and e2 represent the same mapping if

    (e1.getKey()==null ?
     e2.getKey()==null : e1.getKey().equals(e2.getKey()))  &&
    (e1.getValue()==null ?
     e2.getValue()==null : e1.getValue().equals(e2.getValue()))
This ensures that the equals method works properly across different implementations of the Map.Entry interface.
Parameters
o:Object

object to be compared for equality with this map entry.

Returns:boolean

true if the specified object is equal to this map entry.

getKeyback to summary
pack-priv long getKey()

Returns the key corresponding to this entry.

Returns:long

the key corresponding to this entry.

getValueback to summary
pack-priv Object getValue()

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Returns:Object

the value corresponding to this entry.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code value for this map entry. The hash code of a map entry e is defined to be:

    (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
    (e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.
Returns:int

the hash code value for this map entry.

See Also
Object#hashCode(), Object#equals(Object), equals(Object)
setValueback to summary
pack-priv Object setValue(Object value)

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
value:Object

new value to be stored in this entry.

Returns:Object

old value corresponding to the entry.

Exceptions
UnsupportedOperationException:
if the put operation is not supported by the backing map.
ClassCastException:
if the class of the specified value prevents it from being stored in the backing map.
IllegalArgumentException:
if some aspect of this value prevents it from being stored in the backing map.
NullPointerException:
the backing map does not permit null values, and the specified value is null.