public class LongRecordingStackHashMap
extends java.lang.Object
java.util.HashMap
for matching thread ids (long) to recording stacks.| Modifier and Type | Class and Description |
|---|---|
private static class |
LongRecordingStackHashMap.Entry
Implements a bucket entry.
|
| Modifier and Type | Field and Description |
|---|---|
private static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity - MUST be a power of two.
|
private static float |
DEFAULT_LOAD_FACTOR
The load factor used when none specified in constructor.
|
private float |
loadFactor
The load factor for the hash table.
|
private static int |
MAXIMUM_CAPACITY
The maximum capacity, used if a higher value is implicitly specified
by either of the constructors with arguments.
|
private int |
size
The number of key-value mappings contained in this map.
|
private LongRecordingStackHashMap.Entry[] |
table
The table, resized as necessary.
|
private int |
threshold
The next size value at which to resize (capacity * load factor).
|
| Constructor and Description |
|---|
LongRecordingStackHashMap()
Constructs an empty HashMap with the default initial capacity
(16) and the default load factor (0.75).
|
LongRecordingStackHashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial
capacity and the default load factor (0.75).
|
LongRecordingStackHashMap(int initialCapacity,
float loadFactor)
Constructs an empty HashMap with the specified initial
capacity and load factor.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addEntry(int hash,
long key,
RecordingStack value,
int bucketIndex)
Adds a new entry with the specified key, value and hash code to
the specified bucket.
|
void |
clear()
Removes all of the mappings from this map.
|
void |
clone(long from,
long to)
Clones the stack identified with
from
to the stack identified with to. |
boolean |
containsKey(long key)
Returns true if this map contains a mapping for the
specified key.
|
RecordingStack |
get(long key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
(package private) LongRecordingStackHashMap.Entry |
getEntry(long key)
Returns the entry associated with the specified key in the
HashMap.
|
(package private) static int |
hash(long key)
Applies a supplemental hash function to a given hashCode, which
defends against poor quality hash functions.
|
(package private) static int |
indexFor(int hash,
int length)
Returns index for hash code h.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
RecordingStack |
put(long key,
RecordingStack value)
Associates the specified value with the specified key in this map.
|
void |
remove(long key)
Removes the mapping of
key and returns its value. |
(package private) void |
resize(int newCapacity)
Rehashes the contents of this map into a new array with a
larger capacity.
|
int |
size()
Returns the number of key-value mappings in this map.
|
(package private) void |
transfer(LongRecordingStackHashMap.Entry[] newTable)
Transfers all entries from current table to newTable.
|
private static final int DEFAULT_INITIAL_CAPACITY
private static final int MAXIMUM_CAPACITY
private static final float DEFAULT_LOAD_FACTOR
private transient LongRecordingStackHashMap.Entry[] table
private transient int size
private int threshold
private final float loadFactor
public LongRecordingStackHashMap(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factorjava.lang.IllegalArgumentException - if the initial capacity is negative
or the load factor is nonpositivepublic LongRecordingStackHashMap(int initialCapacity)
initialCapacity - the initial capacity.java.lang.IllegalArgumentException - if the initial capacity is negative.public LongRecordingStackHashMap()
public boolean containsKey(long key)
key - The key whose presence in this map is to be testedstatic int hash(long key)
key - the key to hashfinal LongRecordingStackHashMap.Entry getEntry(long key)
key - the key to return the stored object forstatic int indexFor(int hash,
int length)
hash - the hash codelength - the length of the tablepublic RecordingStack put(long key, RecordingStack value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyvoid addEntry(int hash,
long key,
RecordingStack value,
int bucketIndex)
hash - the hash codekey - the key to addvalue - the value to addbucketIndex - the target bucket indexvoid resize(int newCapacity)
newCapacity - the new capacity, MUST be a power of two;
must be greater than current capacity unless current
capacity is MAXIMUM_CAPACITY (in which case value
is irrelevant).void transfer(LongRecordingStackHashMap.Entry[] newTable)
newTable - the target tablepublic RecordingStack get(long key)
null if this map contains no mapping for the key.key - the key to search forput(long, RecordingStack)public void remove(long key)
key and returns its value.key - the key to remove the entrypublic int size()
public boolean isEmpty()
public void clear()
public void clone(long from,
long to)
from
to the stack identified with to.from - the source stackto - the target stack