Class LongObjectHashMap<V>
java.lang.Object
smile.util.LongObjectHashMap<V>
- Type Parameters:
V- the type of values.
- All Implemented Interfaces:
Serializable
An open-addressing hash map from primitive
long keys to object
values. Avoids autoboxing of keys entirely.
Long.MIN_VALUE (0x8000000000000000L) is reserved as the free-slot
sentinel and must not be used as a key.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty map with default capacity 16 and load factor 0.75.LongObjectHashMap(int initialCapacity, float loadFactor) Constructs an empty map. -
Method Summary
Modifier and TypeMethodDescriptionget(long key) Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.booleanisEmpty()Returnstrueif this map contains no entries.Associates the specified value with the specified key.putIfAbsent(long key, V value) If the specified key is not already associated with a value, associates it with the given value and returnsnull; otherwise returns the current value.intsize()Returns the number of key-value mappings.
-
Constructor Details
-
LongObjectHashMap
public LongObjectHashMap()Constructs an empty map with default capacity 16 and load factor 0.75. -
LongObjectHashMap
public LongObjectHashMap(int initialCapacity, float loadFactor) Constructs an empty map.- Parameters:
initialCapacity- the initial capacity (will be rounded up to a power of two).loadFactor- the load factor, must be in (0, 1).
-
-
Method Details
-
size
public int size()Returns the number of key-value mappings.- Returns:
- the number of entries.
-
isEmpty
public boolean isEmpty()Returnstrueif this map contains no entries.- Returns:
trueif empty.
-
get
Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.- Parameters:
key- the key (must not beLong.MIN_VALUE).- Returns:
- the value, or
nullif absent.
-
put
-
putIfAbsent
If the specified key is not already associated with a value, associates it with the given value and returnsnull; otherwise returns the current value.- Parameters:
key- the key.value- the value to insert if absent.- Returns:
- the existing value if present, else
null.
-