class FastCopyHashMap<K,V>
extends java.util.AbstractMap<K,V>
implements java.util.Map<K,V>, java.lang.Cloneable, java.io.Serializable
HashMap
.
Note: It is very important to use a smaller load factor than you normally
would for HashMap, since the implementation is open-addressed with linear
probing. With a 50% load-factor a get is expected to return in only 2 probes.
However, a 90% load-factor is expected to return in around 50 probes.Modifier and Type | Class and Description |
---|---|
private static class |
FastCopyHashMap.Entry<K,V> |
private class |
FastCopyHashMap.EntryIterator |
private class |
FastCopyHashMap.EntrySet |
private class |
FastCopyHashMap.FastCopyHashMapIterator<E> |
private class |
FastCopyHashMap.KeyIterator |
private class |
FastCopyHashMap.KeySet |
protected static class |
FastCopyHashMap.SimpleEntry<K,V> |
private class |
FastCopyHashMap.ValueIterator |
private class |
FastCopyHashMap.Values |
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_CAPACITY
Same default as HashMap, must be a power of 2
|
private static float |
DEFAULT_LOAD_FACTOR
67%, just like IdentityHashMap
|
private FastCopyHashMap.EntrySet |
entrySet |
private FastCopyHashMap.KeySet |
keySet |
private float |
loadFactor
The user defined load factor which defines when to resize
|
private static int |
MAXIMUM_CAPACITY
MAX_INT - 1
|
private int |
modCount
Counter used to detect changes made outside of an iterator
|
private static java.lang.Object |
NULL
Marks null keys.
|
private static long |
serialVersionUID
Serialization ID
|
private int |
size
The current number of key-value pairs
|
private FastCopyHashMap.Entry<K,V>[] |
table
The open-addressed table
|
private int |
threshold
The next resize
|
private FastCopyHashMap.Values |
values |
Constructor and Description |
---|
FastCopyHashMap() |
FastCopyHashMap(int initialCapacity) |
FastCopyHashMap(int initialCapacity,
float loadFactor) |
FastCopyHashMap(java.util.Map<? extends K,? extends V> map) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
FastCopyHashMap<K,V> |
clone() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
private static boolean |
eq(java.lang.Object o1,
java.lang.Object o2) |
V |
get(java.lang.Object key) |
private static int |
hash(java.lang.Object key) |
private static int |
index(int hashCode,
int length) |
private void |
init(int initialCapacity,
float loadFactor) |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
private static <K> K |
maskNull(K key) |
private int |
nextIndex(int index,
int length) |
void |
printDebugStats() |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> map) |
private void |
putForCreate(K key,
V value) |
private void |
readObject(java.io.ObjectInputStream s) |
private void |
relocate(int start) |
V |
remove(java.lang.Object key) |
private void |
resize(int from) |
int |
size() |
private static <K> K |
unmaskNull(K key) |
java.util.Collection<V> |
values() |
private void |
writeObject(java.io.ObjectOutputStream s) |
private static final java.lang.Object NULL
private static final long serialVersionUID
private static final int DEFAULT_CAPACITY
private static final int MAXIMUM_CAPACITY
private static final float DEFAULT_LOAD_FACTOR
private transient FastCopyHashMap.Entry<K,V>[] table
private transient int size
private transient int threshold
private final float loadFactor
private transient int modCount
private transient FastCopyHashMap.KeySet keySet
private transient FastCopyHashMap.Values values
private transient FastCopyHashMap.EntrySet entrySet
public FastCopyHashMap(int initialCapacity, float loadFactor)
public FastCopyHashMap(int initialCapacity)
public FastCopyHashMap()
private void init(int initialCapacity, float loadFactor)
private static final int hash(java.lang.Object key)
private static final <K> K maskNull(K key)
private static final <K> K unmaskNull(K key)
private int nextIndex(int index, int length)
private static final boolean eq(java.lang.Object o1, java.lang.Object o2)
private static final int index(int hashCode, int length)
public int size()
public boolean isEmpty()
public V get(java.lang.Object key)
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
private void resize(int from)
public V remove(java.lang.Object key)
private void relocate(int start)
public void clear()
public FastCopyHashMap<K,V> clone()
public void printDebugStats()
public java.util.Set<K> keySet()
public java.util.Collection<V> values()
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
java.io.IOException