V
- The value type stored in the map.public class ShortObjectHashMap<V> extends Object implements ShortObjectMap<V>
ShortObjectMap
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.ShortObjectMap.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 |
---|
ShortObjectHashMap() |
ShortObjectHashMap(int initialCapacity) |
ShortObjectHashMap(int initialCapacity,
float loadFactor) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsKey(short key)
Indicates whether or not this map contains a value for the specified key.
|
boolean |
containsValue(Object value) |
Iterable<ShortObjectMap.PrimitiveEntry<V>> |
entries()
Gets an iterable to traverse over the primitive entries contained in this map.
|
Set<Map.Entry<Short,V>> |
entrySet() |
boolean |
equals(Object obj) |
V |
get(Object key) |
V |
get(short key)
Gets the value in the map with the specified key.
|
int |
hashCode() |
boolean |
isEmpty() |
Set<Short> |
keySet() |
protected String |
keyToString(short key)
Helper method called by
toString() in order to convert a single map key into a string. |
V |
put(short key,
V value)
Puts the given entry into the map.
|
V |
put(Short key,
V value) |
void |
putAll(Map<? extends Short,? extends V> sourceMap) |
V |
remove(Object key) |
V |
remove(short key)
Removes the entry with the specified 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 ShortObjectHashMap()
public ShortObjectHashMap(int initialCapacity)
public ShortObjectHashMap(int initialCapacity, float loadFactor)
public V get(short key)
ShortObjectMap
get
in interface ShortObjectMap<V>
key
- the key whose associated value is to be returned.null
if the key was not found in the map.public V put(short key, V value)
ShortObjectMap
put
in interface ShortObjectMap<V>
key
- the key of the entry.value
- the value of the entry.null
if there was no previous mapping.public V remove(short key)
ShortObjectMap
remove
in interface ShortObjectMap<V>
key
- the key for the entry to be removed from this map.null
if there was no mapping.public boolean containsKey(short key)
ShortObjectMap
containsKey
in interface ShortObjectMap<V>
public boolean containsValue(Object value)
containsValue
in interface Map<Short,V>
public Iterable<ShortObjectMap.PrimitiveEntry<V>> entries()
ShortObjectMap
ShortObjectMap.PrimitiveEntry
s returned by the Iterator
may change as the Iterator
progresses. The caller should not rely on ShortObjectMap.PrimitiveEntry
key/value stability.entries
in interface ShortObjectMap<V>
public int hashCode()
public boolean equals(Object obj)
public boolean containsKey(Object key)
containsKey
in interface Map<Short,V>
protected String keyToString(short 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.Copyright © 2008–2017 The Netty Project. All rights reserved.