public class IdentityMap<K,V>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
IdentityMap.Entries<K,V> |
static class |
IdentityMap.Entry<K,V> |
static class |
IdentityMap.Keys<K> |
private static class |
IdentityMap.MapIterator<K,V> |
static class |
IdentityMap.Values<V> |
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
capacity |
private IdentityMap.Entries |
entries |
private int |
hashShift |
private IdentityMap.Keys |
keys |
(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 |
private IdentityMap.Values |
values |
(package private) V[] |
valueTable |
| Constructor and Description |
|---|
IdentityMap()
Creates a new map with an initial capacity of 32 and a load factor of 0.8.
|
IdentityMap(int initialCapacity)
Creates a new map with a load factor of 0.8.
|
IdentityMap(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(java.lang.Object value,
boolean identity)
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.
|
IdentityMap.Entries<K,V> |
entries()
Returns an iterator for the entries in the map.
|
K |
findKey(java.lang.Object value,
boolean identity)
Returns the key for the specified value, or null if it is not in the map.
|
V |
get(K key) |
V |
get(K key,
V defaultValue) |
private V |
getStash(K key,
V defaultValue) |
private int |
hash2(int h) |
private int |
hash3(int h) |
IdentityMap.Keys<K> |
keys()
Returns an iterator for the keys in the map.
|
private void |
push(K insertKey,
V insertValue,
int index1,
K key1,
int index2,
K key2,
int index3,
K key3) |
V |
put(K key,
V value) |
private void |
putResize(K key,
V value)
Skips checks for existing keys.
|
private void |
putStash(K key,
V value) |
V |
remove(K key) |
(package private) V |
removeStash(K key) |
(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() |
IdentityMap.Values<V> |
values()
Returns an iterator for the values in the map.
|
private static final int PRIME1
private static final int PRIME2
private static final int PRIME3
public int size
K[] keyTable
V[] valueTable
int capacity
int stashSize
private float loadFactor
private int hashShift
private int mask
private int threshold
private int stashCapacity
private int pushIterations
private IdentityMap.Entries entries
private IdentityMap.Values values
private IdentityMap.Keys keys
public IdentityMap()
public IdentityMap(int initialCapacity)
public IdentityMap(int initialCapacity,
float loadFactor)
private void push(K insertKey, V insertValue, int index1, K key1, int index2, K key2, int index3, K key3)
void removeStashIndex(int index)
public void shrink(int maximumCapacity)
public void clear(int maximumCapacity)
public void clear()
public boolean containsValue(java.lang.Object value,
boolean identity)
identity - If true, uses == to compare the specified value with values in the map. If false, uses
Object.equals(Object).public boolean containsKey(K key)
private boolean containsKeyStash(K key)
public K findKey(java.lang.Object value, boolean identity)
identity - If true, uses == to compare the specified value with values in the map. If false, uses
Object.equals(Object).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.Objectpublic IdentityMap.Entries<K,V> entries()
IdentityMap.Entries constructor for nested or multithreaded iteration.public IdentityMap.Values<V> values()
IdentityMap.Entries constructor for nested or multithreaded iteration.public IdentityMap.Keys<K> keys()
IdentityMap.Entries constructor for nested or multithreaded iteration.