Package one.pkg.tinyutils.map
Class WeakObject2LongHashMap<K>
java.lang.Object
one.pkg.tinyutils.map.WeakObject2LongHashMap<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 long values.
Similar to
WeakHashMap, an entry is automatically removed when its key
is no longer ordinarily reachable.-
Constructor Summary
ConstructorsConstructorDescriptionWeakObject2LongHashMap(int expected) WeakObject2LongHashMap(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.longGets the default return value for this map.voiddefaultReturnValue(long rv) Sets the default return value for this map.longReturns the value to which the specified key is mapped.longgetOrDefault(K key, long 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.longAssociates the specified value with the specified key in this map.longRemoves 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
-
WeakObject2LongHashMap
public WeakObject2LongHashMap() -
WeakObject2LongHashMap
public WeakObject2LongHashMap(int expected) -
WeakObject2LongHashMap
public WeakObject2LongHashMap(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. -
getLong
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(long rv) Sets the default return value for this map. -
defaultReturnValue
public long defaultReturnValue()Gets the default return value for this map.
-