java.lang.Object
java.util.AbstractMap<K,V>
org.pcollections.AbstractUnmodifiableMap<K,V>
org.pcollections.HashPMap<K,V>
- Type Parameters:
K
-V
-
- All Implemented Interfaces:
Serializable
,Map<K,
,V> PMap<K,
V>
public final class HashPMap<K,V>
extends AbstractUnmodifiableMap<K,V>
implements PMap<K,V>, Serializable
A persistent map from keys to values. Keys and values can be null.
This map uses a given integer map to map hashcodes to lists of elements with the same hashcode. Thus if all elements have the same hashcode, performance is reduced to that of an association list.
This implementation is thread-safe (assuming Java's AbstractMap and AbstractSet are thread-safe), although its iterators may not be.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) static <K,
V> HashPMap <K, V> entrySet()
getEntries
(int hash) private static <K,
V> int keyIndexIn
(PSequence<Map.Entry<K, V>> entries, Object key) minusAll
(Collection<?> keys) int
size()
Methods inherited from class org.pcollections.AbstractUnmodifiableMap
clear, compute, computeIfAbsent, computeIfPresent, merge, put, putAll, putIfAbsent, remove, replace, replaceAll
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, values
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
intMap
-
size
private final int size -
entrySet
-
-
Constructor Details
-
HashPMap
-
-
Method Details
-
empty
- Type Parameters:
K
-V
-- Parameters:
intMap
-- Returns:
- a map backed by an empty version of intMap, i.e. backed by intMap.minusAll(intMap.keySet())
-
entrySet
-
size
public int size() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractMap<K,
V>
-
get
-
plusAll
-
minusAll
-
plus
-
minus
-
getEntries
-
keyIndexIn
-