Package one.pkg.tinyutils.map
Class WeakObject2IntHashMap<K>
java.lang.Object
one.pkg.tinyutils.map.WeakObject2IntHashMap<K>
- Type Parameters:
K- the type of keys maintained by this map
A Map-like data structure that uses weakly referenced Object keys and primitive int values.
Similar to
WeakHashMap, an entry is automatically removed when its key
is no longer ordinarily reachable.-
Constructor Summary
ConstructorsConstructorDescriptionWeakObject2IntHashMap(int expected) WeakObject2IntHashMap(int expected, float f) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the mappings from this map.booleancontainsKey(K key) Returnstrueif this map contains a mapping for the specified key.intGets the default return value for this map.voiddefaultReturnValue(int rv) Sets the default return value for this map.intReturns the value to which the specified key is mapped.intgetOrDefault(K key, int defaultValue) Returns the value to which the specified key is mapped, or the given default value if this map contains no mapping for the key.booleanisEmpty()Returnstrueif this map contains no key-value mappings.intAssociates the specified value with the specified key in this map.intRemoves the mapping for a key from this map if it is present.intsize()Returns the number of key-value mappings in this map.
-
Constructor Details
-
WeakObject2IntHashMap
public WeakObject2IntHashMap() -
WeakObject2IntHashMap
public WeakObject2IntHashMap(int expected) -
WeakObject2IntHashMap
public WeakObject2IntHashMap(int expected, float f)
-
-
Method Details
-
size
public int size()Returns the number of key-value mappings in this map. -
isEmpty
public boolean isEmpty()Returnstrueif this map contains no key-value mappings. -
getInt
Returns the value to which the specified key is mapped. Returns the map's default return value (usually 0) if this map contains no mapping for the key. -
getOrDefault
Returns the value to which the specified key is mapped, or the given default value if this map contains no mapping for the key. -
put
Associates the specified value with the specified key in this map.- Returns:
- the previous value associated with
key, or the default value (usually 0) if there was no mapping forkey.
-
remove
Removes the mapping for a key from this map if it is present.- Returns:
- the previous value associated with
key, or the default value (usually 0) if there was no mapping forkey.
-
containsKey
Returnstrueif this map contains a mapping for the specified key. -
clear
public void clear()Removes all of the mappings from this map. -
defaultReturnValue
public void defaultReturnValue(int rv) Sets the default return value for this map. -
defaultReturnValue
public int defaultReturnValue()Gets the default return value for this map.
-