- java.lang.Object
-
- swim.collections.BTreeContext<K,V>
-
- swim.collections.BTreeMap<K,V,U>
-
- All Implemented Interfaces:
Cloneable
,Iterable<Map.Entry<K,V>>
,Map<K,V>
,SortedMap<K,V>
,Debug
,IterableMap<K,V>
,OrderedMap<K,V>
,ReducedMap<K,V,U>
public class BTreeMap<K,V,U> extends BTreeContext<K,V> implements ReducedMap<K,V,U>, Cloneable, Debug
Mutable, thread-safeMap
backed by a B-tree.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
BTreeMap<K,V,U>
cleared()
BTreeMap<K,V,U>
clone()
Comparator<? super K>
comparator()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
protected BTreeMap<K,V,U>
copy(BTreePage<K,V,U> root)
<T> Output<T>
debug(Output<T> output)
Writes a developer readable, debug-formatted string representation of this object tooutput
.BTreeMap<K,V,U>
drop(int lower)
static <K,V,U>
BTreeMap<K,V,U>empty()
boolean
equals(Object other)
Map.Entry<K,V>
firstEntry()
K
firstKey()
V
firstValue()
static <K,V,U>
BTreeMap<K,V,U>from(Map<? extends K,? extends V> map)
V
get(Object key)
Map.Entry<K,V>
getEntry(Object key)
Map.Entry<K,V>
getIndex(int index)
int
hashCode()
int
indexOf(Object key)
boolean
isEmpty()
OrderedMapCursor<K,V>
iterator()
Cursor<K>
keyIterator()
Map.Entry<K,V>
lastEntry()
K
lastKey()
V
lastValue()
Map.Entry<K,V>
nextEntry(K key)
K
nextKey(K key)
V
nextValue(K key)
Map.Entry<K,V>
previousEntry(K key)
K
previousKey(K key)
V
previousValue(K key)
V
put(K key, V newValue)
void
putAll(Map<? extends K,? extends V> map)
U
reduced(U identity, CombinerFunction<? super V,U> accumulator, CombinerFunction<U,U> combiner)
Returns the reduction of thisReducedMap
, combining all contained elements with the givenaccumulator
andcombiner
functions, recomputing only what has changed since the last invocation ofreduced
.V
remove(Object key)
BTreeMap<K,V,U>
removed(K key)
OrderedMapCursor<K,V>
reverseIterator()
Cursor<K>
reverseKeyIterator()
Cursor<V>
reverseValueIterator()
int
size()
BTree<K,V>
snapshot()
An immutable copy of thisBTreeMap
's data.BTreeMap<K,V,U>
take(int upper)
String
toString()
BTreeMap<K,V,U>
updated(K key, V newValue)
Cursor<V>
valueIterator()
-
Methods inherited from class swim.collections.BTreeContext
compareKey, pageShouldMerge, pageShouldSplit, pageSplitSize
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceIterableMap<K,V>
- Specified by:
containsKey
in interfaceMap<K,V>
- Specified by:
containsKey
in interfaceOrderedMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceIterableMap<K,V>
- Specified by:
containsValue
in interfaceMap<K,V>
- Specified by:
containsValue
in interfaceOrderedMap<K,V>
-
indexOf
public int indexOf(Object key)
- Specified by:
indexOf
in interfaceOrderedMap<K,V>
-
getEntry
public Map.Entry<K,V> getEntry(Object key)
- Specified by:
getEntry
in interfaceOrderedMap<K,V>
-
getIndex
public Map.Entry<K,V> getIndex(int index)
- Specified by:
getIndex
in interfaceOrderedMap<K,V>
-
firstEntry
public Map.Entry<K,V> firstEntry()
- Specified by:
firstEntry
in interfaceOrderedMap<K,V>
-
firstKey
public K firstKey()
-
firstValue
public V firstValue()
- Specified by:
firstValue
in interfaceOrderedMap<K,V>
-
lastKey
public K lastKey()
-
lastValue
public V lastValue()
- Specified by:
lastValue
in interfaceOrderedMap<K,V>
-
nextEntry
public Map.Entry<K,V> nextEntry(K key)
- Specified by:
nextEntry
in interfaceOrderedMap<K,V>
-
previousEntry
public Map.Entry<K,V> previousEntry(K key)
- Specified by:
previousEntry
in interfaceOrderedMap<K,V>
-
previousKey
public K previousKey(K key)
- Specified by:
previousKey
in interfaceOrderedMap<K,V>
-
previousValue
public V previousValue(K key)
- Specified by:
previousValue
in interfaceOrderedMap<K,V>
-
clear
public void clear()
-
reduced
public U reduced(U identity, CombinerFunction<? super V,U> accumulator, CombinerFunction<U,U> combiner)
Description copied from interface:ReducedMap
Returns the reduction of thisReducedMap
, combining all contained elements with the givenaccumulator
andcombiner
functions, recomputing only what has changed since the last invocation ofreduced
. Stores partial computations to accelerate repeated reduction of continuously mutating datasets.- Specified by:
reduced
in interfaceReducedMap<K,V,U>
-
iterator
public OrderedMapCursor<K,V> iterator()
-
keyIterator
public Cursor<K> keyIterator()
- Specified by:
keyIterator
in interfaceIterableMap<K,V>
- Specified by:
keyIterator
in interfaceOrderedMap<K,V>
-
valueIterator
public Cursor<V> valueIterator()
- Specified by:
valueIterator
in interfaceIterableMap<K,V>
- Specified by:
valueIterator
in interfaceOrderedMap<K,V>
-
reverseIterator
public OrderedMapCursor<K,V> reverseIterator()
-
comparator
public Comparator<? super K> comparator()
- Specified by:
comparator
in interfaceOrderedMap<K,V>
- Specified by:
comparator
in interfaceSortedMap<K,V>
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
debug
public <T> Output<T> debug(Output<T> output)
Description copied from interface:Debug
Writes a developer readable, debug-formatted string representation of this object tooutput
.
-
empty
public static <K,V,U> BTreeMap<K,V,U> empty()
-
-