org.pcollections
Class HashPMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
org.pcollections.HashPMap<K,V>
- Type Parameters:
K - V -
- All Implemented Interfaces:
- Map<K,V>, PMap<K,V>
public final class HashPMap<K,V>
- extends AbstractMap<K,V>
- implements PMap<K,V>
A persistent map from non-null keys to non-null values.
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.
- Author:
- harold
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
| Methods inherited from class java.util.AbstractMap |
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, toString, values |
empty
public static <K,V> HashPMap<K,V> empty(PMap<Integer,PSequence<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())
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySet in interface Map<K,V>- Specified by:
entrySet in class AbstractMap<K,V>
size
public int size()
- Specified by:
size in interface Map<K,V>- Overrides:
size in class AbstractMap<K,V>
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey in interface Map<K,V>- Overrides:
containsKey in class AbstractMap<K,V>
get
public V get(Object key)
- Specified by:
get in interface Map<K,V>- Overrides:
get in class AbstractMap<K,V>
plusAll
public HashPMap<K,V> plusAll(Map<? extends K,? extends V> map)
- Specified by:
plusAll in interface PMap<K,V>
- Returns:
- this combined with map, with map's mappings used for any keys in both map and this
minusAll
public HashPMap<K,V> minusAll(Collection<?> keys)
- Specified by:
minusAll in interface PMap<K,V>
- Returns:
- a map with the mappings of this but with no value for any element of keys
plus
public HashPMap<K,V> plus(K key,
V value)
- Specified by:
plus in interface PMap<K,V>
- Parameters:
key - non-nullvalue - non-null
- Returns:
- a map with the mappings of this but with key mapped to value
minus
public HashPMap<K,V> minus(Object key)
- Specified by:
minus in interface PMap<K,V>
- Returns:
- a map with the mappings of this but with no value for key
Copyright © 2011. All Rights Reserved.