public class IdentityObjectIntMap<K>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
capacity |
private int |
hashShift |
(package private) K[] |
keyTable |
private float |
loadFactor |
private int |
mask |
private static int |
PRIME1 |
private static int |
PRIME2 |
private static int |
PRIME3 |
private int |
pushIterations |
int |
size |
private int |
stashCapacity |
(package private) int |
stashSize |
private int |
threshold |
(package private) int[] |
valueTable |
| Constructor and Description |
|---|
IdentityObjectIntMap()
Creates a new map with an initial capacity of 32 and a load factor of 0.8.
|
IdentityObjectIntMap(int initialCapacity)
Creates a new map with a load factor of 0.8.
|
IdentityObjectIntMap(int initialCapacity,
float loadFactor)
Creates a new map with the specified initial capacity and load factor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
clear(int maximumCapacity)
Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger.
|
boolean |
containsKey(K key) |
private boolean |
containsKeyStash(K key) |
boolean |
containsValue(int value)
Returns true if the specified value is in the map.
|
void |
ensureCapacity(int additionalCapacity)
Increases the size of the backing array to acommodate the specified number of additional items.
|
K |
findKey(int value)
Returns the key for the specified value, or null if it is not in the map.
|
int |
get(K key,
int defaultValue) |
int |
getAndIncrement(K key,
int defaultValue,
int increment)
Returns the key's current value and increments the stored value.
|
private int |
getAndIncrementStash(K key,
int defaultValue,
int increment) |
private int |
getStash(K key,
int defaultValue) |
private int |
hash2(int h) |
private int |
hash3(int h) |
private void |
push(K insertKey,
int insertValue,
int index1,
K key1,
int index2,
K key2,
int index3,
K key3) |
void |
put(K key,
int value) |
private void |
putResize(K key,
int value)
Skips checks for existing keys.
|
private void |
putStash(K key,
int value) |
int |
remove(K key,
int defaultValue) |
(package private) int |
removeStash(K key,
int defaultValue) |
(package private) void |
removeStashIndex(int index) |
private void |
resize(int newSize) |
void |
shrink(int maximumCapacity)
Reduces the size of the backing arrays to be the specified capacity or less.
|
java.lang.String |
toString() |
private static final int PRIME1
private static final int PRIME2
private static final int PRIME3
public int size
K[] keyTable
int[] valueTable
int capacity
int stashSize
private float loadFactor
private int hashShift
private int mask
private int threshold
private int stashCapacity
private int pushIterations
public IdentityObjectIntMap()
public IdentityObjectIntMap(int initialCapacity)
public IdentityObjectIntMap(int initialCapacity,
float loadFactor)
public void put(K key, int value)
private void putResize(K key, int value)
private void push(K insertKey, int insertValue, int index1, K key1, int index2, K key2, int index3, K key3)
private void putStash(K key, int value)
public int get(K key, int defaultValue)
defaultValue - Returned if the key was not associated with a value.private int getStash(K key, int defaultValue)
public int getAndIncrement(K key, int defaultValue, int increment)
private int getAndIncrementStash(K key, int defaultValue, int increment)
public int remove(K key, int defaultValue)
int removeStash(K key, int defaultValue)
void removeStashIndex(int index)
public void shrink(int maximumCapacity)
public void clear(int maximumCapacity)
public void clear()
public boolean containsValue(int value)
public boolean containsKey(K key)
private boolean containsKeyStash(K key)
public K findKey(int value)
public void ensureCapacity(int additionalCapacity)
private void resize(int newSize)
private int hash2(int h)
private int hash3(int h)
public java.lang.String toString()
toString in class java.lang.Object