Class LongMap<V>
- All Implemented Interfaces:
Serializable, Cloneable, Map<Long,V>
@NotThreadSafe
public class LongMap<V>
extends AbstractMap<Long,V>
implements Cloneable, Serializable
A map with non-zero
long keys.
This implementation uses long[] arrays and open addressing to minimize memory overhead.
Equivalent Map methods taking long instead of Long are also provided.
Instances will throw IllegalStateException if their capacity is exceeded.
Instances do not accept zero keys and are not thread safe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()clone()booleancontainsKey(long key) booleancontainsKey(Object obj) deepClone(UnaryOperator<V> valueCloner) Perform a "deep clone" operation, which is a normalclone()followed by a cloning of each value using the provided clone function.entrySet()booleanget(long key) inthashCode()booleanisEmpty()keySet()remove(long key) Remove a single, arbitrary entry from this instance and return it.intsize()Methods inherited from class AbstractMap
containsValue, putAll, toString, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
LongMap
public LongMap()Constructs an empty instance. -
LongMap
public LongMap(int capacity) Constructs an instance with the given initial capacity.- Parameters:
capacity- initial capacity- Throws:
IllegalArgumentException- ifcapacityis negative
-
LongMap
Constructs an instance initialized from the given map.- Parameters:
map- initial contents for this instance- Throws:
NullPointerException- ifmapis nullIllegalArgumentException- ifmapcontains a null key
-
-
Method Details
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<Long,V> - Overrides:
containsKeyin classAbstractMap<Long,V>
-
containsKey
public boolean containsKey(long key) -
get
-
get
-
put
-
put
-
remove
-
remove
-
clear
-
keySet
-
entrySet
-
removeOne
-
hashCode
-
equals
-
clone
-
deepClone
Perform a "deep clone" operation, which is a normalclone()followed by a cloning of each value using the provided clone function.- Parameters:
valueCloner- used to clone the individual values in this map- Returns:
- a deeply cloned copy of this instance
- Throws:
IllegalArgumentException- ifvalueCloneris null
-