- Type Parameters:
V
-
- All Implemented Interfaces:
Serializable
,Map<Integer,
,V> PMap<Integer,
V>
public final class IntTreePMap<V>
extends AbstractUnmodifiableMap<Integer,V>
implements PMap<Integer,V>, Serializable
An efficient persistent map from integer keys to values. Null values are supported.
Iteration occurs in the integer order of the keys.
This implementation is thread-safe (assuming Java's AbstractMap and AbstractSet are thread-safe), although its iterators may not be.
The balanced tree is based on the Glasgow Haskell Compiler's Data.Map implementation, which in turn is based on "size balanced binary trees" as described by:
Stephen Adams, "Efficient sets: a balancing act", Journal of Functional Programming 3(4):553-562, October 1993, http://www.swiss.ai.mit.edu/~adams/BB/.
J. Nievergelt and E.M. Reingold, "Binary search trees of bounded balance", SIAM journal of computing 2(1), March 1973.
- See Also:
-
Nested Class Summary
Nested 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 <V> IntTreePMap
<V> empty()
entrySet()
static <V> IntTreePMap
<V> minusAll
(Collection<?> keys) minusRange
(int start, int end) static <V> IntTreePMap
<V> int
size()
(package private) IntTreePMap
<V> withKeysChangedAbove
(int key, int delta) (package private) IntTreePMap
<V> withKeysChangedBelow
(int key, int delta) private IntTreePMap
<V> 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:
-
EMPTY
-
root
-
entrySet
-
-
Constructor Details
-
IntTreePMap
-
-
Method Details
-
empty
- Type Parameters:
V
-- Returns:
- an empty map
-
singleton
- Type Parameters:
V
-- Parameters:
key
-value
-- Returns:
- empty().plus(key, value)
-
from
- Type Parameters:
V
-- Parameters:
map
-- Returns:
- empty().plusAll(map)
-
withRoot
-
minusRange
- Parameters:
start
-end
-- Returns:
- this map but with all keys start≤k<end removed
-
withKeysChangedAbove
-
withKeysChangedBelow
-
entrySet
-
size
public int size() -
containsKey
- Specified by:
containsKey
in interfaceMap<Integer,
V> - Overrides:
containsKey
in classAbstractMap<Integer,
V>
-
get
-
plus
-
minus
-
plusAll
-
minusAll
-