V
- The value type stored in the map.public class SynchronizedIntObjectHashMap<V> extends Object implements IntObjectMap<V>
IntObjectMap
that uses open addressing for keys. To minimize
the memory footprint, this class uses open addressing rather than chaining. Collisions are
resolved using linear probing. Deletions implement compaction, so cost of remove can approach
O(N) for full maps, which makes a small loadFactor recommended.IntObjectMap.PrimitiveEntry<V>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CAPACITY
Default initial capacity.
|
static float |
DEFAULT_LOAD_FACTOR
Default load factor.
|
Constructor and Description |
---|
SynchronizedIntObjectHashMap() |
SynchronizedIntObjectHashMap(int initialCapacity) |
SynchronizedIntObjectHashMap(int initialCapacity,
float loadFactor) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(int key) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Iterable<IntObjectMap.PrimitiveEntry<V>> |
entries() |
Set<Map.Entry<Integer,V>> |
entrySet() |
boolean |
equals(Object obj) |
V |
get(int key) |
V |
get(Object key) |
V[] |
getValuesCopy() |
int |
hashCode() |
boolean |
isEmpty() |
Set<Integer> |
keySet() |
protected String |
keyToString(int key)
Helper method called by
toString() in order to convert a single map key into a string. |
V |
put(Integer key,
V value) |
V |
put(int key,
V value) |
void |
putAll(Map<? extends Integer,? extends V> sourceMap) |
V |
remove(int key) |
V |
remove(Object key) |
int |
size() |
String |
toString() |
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static final int DEFAULT_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
public SynchronizedIntObjectHashMap()
public SynchronizedIntObjectHashMap(int initialCapacity)
public SynchronizedIntObjectHashMap(int initialCapacity, float loadFactor)
public V[] getValuesCopy()
public V get(int key)
get
in interface IntObjectMap<V>
public V put(int key, V value)
put
in interface IntObjectMap<V>
public V remove(int key)
remove
in interface IntObjectMap<V>
public boolean containsKey(int key)
containsKey
in interface IntObjectMap<V>
public boolean containsValue(Object value)
containsValue
in interface Map<Integer,V>
public Iterable<IntObjectMap.PrimitiveEntry<V>> entries()
entries
in interface IntObjectMap<V>
public int hashCode()
public boolean equals(Object obj)
public boolean containsKey(Object key)
containsKey
in interface Map<Integer,V>
protected String keyToString(int key)
toString()
in order to convert a single map key into a string.
This is protected to allow subclasses to override the appearance of a given key.