- 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:
java.io.Serializable
,java.util.Map<K,V>
,PMap<K,V>
public final class HashPMap<K,V> extends AbstractUnmodifiableMap<K,V> implements PMap<K,V>, java.io.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
HashPMap.SequenceIterator<E>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.Object key)
static <K,V>
HashPMap<K,V>empty(PMap<java.lang.Integer,PSequence<java.util.Map.Entry<K,V>>> intMap)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
private PSequence<java.util.Map.Entry<K,V>>
getEntries(int hash)
private static <K,V>
intkeyIndexIn(PSequence<java.util.Map.Entry<K,V>> entries, java.lang.Object key)
HashPMap<K,V>
minus(java.lang.Object key)
HashPMap<K,V>
minusAll(java.util.Collection<?> keys)
HashPMap<K,V>
plus(K key, V value)
HashPMap<K,V>
plusAll(java.util.Map<? extends K,? extends V> map)
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
-
-
-
-
Method Detail
-
empty
public static <K,V> HashPMap<K,V> empty(PMap<java.lang.Integer,PSequence<java.util.Map.Entry<K,V>>> intMap)
- Type Parameters:
K
-V
-- Parameters:
intMap
-- Returns:
- a map backed by an empty version of intMap, i.e. backed by intMap.minusAll(intMap.keySet())
-
size
public int size()
-
containsKey
public boolean containsKey(java.lang.Object key)
-
get
public V get(java.lang.Object key)
-
keyIndexIn
private static <K,V> int keyIndexIn(PSequence<java.util.Map.Entry<K,V>> entries, java.lang.Object key)
-
-