- 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-safeMapbacked by a B-tree.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()BTreeMap<K,V,U>cleared()BTreeMap<K,V,U>clone()Comparator<? super K>comparator()booleancontainsKey(Object key)booleancontainsValue(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()booleanequals(Object other)Map.Entry<K,V>firstEntry()KfirstKey()VfirstValue()static <K,V,U>
BTreeMap<K,V,U>from(Map<? extends K,? extends V> map)Vget(Object key)Map.Entry<K,V>getEntry(Object key)Map.Entry<K,V>getIndex(int index)inthashCode()intindexOf(Object key)booleanisEmpty()OrderedMapCursor<K,V>iterator()Cursor<K>keyIterator()Map.Entry<K,V>lastEntry()KlastKey()VlastValue()Map.Entry<K,V>nextEntry(K key)KnextKey(K key)VnextValue(K key)Map.Entry<K,V>previousEntry(K key)KpreviousKey(K key)VpreviousValue(K key)Vput(K key, V newValue)voidputAll(Map<? extends K,? extends V> map)Ureduced(U identity, CombinerFunction<? super V,U> accumulator, CombinerFunction<U,U> combiner)Returns the reduction of thisReducedMap, combining all contained elements with the givenaccumulatorandcombinerfunctions, recomputing only what has changed since the last invocation ofreduced.Vremove(Object key)BTreeMap<K,V,U>removed(K key)OrderedMapCursor<K,V>reverseIterator()Cursor<K>reverseKeyIterator()Cursor<V>reverseValueIterator()intsize()BTree<K,V>snapshot()An immutable copy of thisBTreeMap's data.BTreeMap<K,V,U>take(int upper)StringtoString()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:
containsKeyin interfaceIterableMap<K,V>- Specified by:
containsKeyin interfaceMap<K,V>- Specified by:
containsKeyin interfaceOrderedMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceIterableMap<K,V>- Specified by:
containsValuein interfaceMap<K,V>- Specified by:
containsValuein interfaceOrderedMap<K,V>
-
indexOf
public int indexOf(Object key)
- Specified by:
indexOfin interfaceOrderedMap<K,V>
-
getEntry
public Map.Entry<K,V> getEntry(Object key)
- Specified by:
getEntryin interfaceOrderedMap<K,V>
-
getIndex
public Map.Entry<K,V> getIndex(int index)
- Specified by:
getIndexin interfaceOrderedMap<K,V>
-
firstEntry
public Map.Entry<K,V> firstEntry()
- Specified by:
firstEntryin interfaceOrderedMap<K,V>
-
firstKey
public K firstKey()
-
firstValue
public V firstValue()
- Specified by:
firstValuein interfaceOrderedMap<K,V>
-
lastKey
public K lastKey()
-
lastValue
public V lastValue()
- Specified by:
lastValuein interfaceOrderedMap<K,V>
-
nextEntry
public Map.Entry<K,V> nextEntry(K key)
- Specified by:
nextEntryin interfaceOrderedMap<K,V>
-
previousEntry
public Map.Entry<K,V> previousEntry(K key)
- Specified by:
previousEntryin interfaceOrderedMap<K,V>
-
previousKey
public K previousKey(K key)
- Specified by:
previousKeyin interfaceOrderedMap<K,V>
-
previousValue
public V previousValue(K key)
- Specified by:
previousValuein 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:ReducedMapReturns the reduction of thisReducedMap, combining all contained elements with the givenaccumulatorandcombinerfunctions, recomputing only what has changed since the last invocation ofreduced. Stores partial computations to accelerate repeated reduction of continuously mutating datasets.- Specified by:
reducedin interfaceReducedMap<K,V,U>
-
iterator
public OrderedMapCursor<K,V> iterator()
-
keyIterator
public Cursor<K> keyIterator()
- Specified by:
keyIteratorin interfaceIterableMap<K,V>- Specified by:
keyIteratorin interfaceOrderedMap<K,V>
-
valueIterator
public Cursor<V> valueIterator()
- Specified by:
valueIteratorin interfaceIterableMap<K,V>- Specified by:
valueIteratorin interfaceOrderedMap<K,V>
-
reverseIterator
public OrderedMapCursor<K,V> reverseIterator()
-
comparator
public Comparator<? super K> comparator()
- Specified by:
comparatorin interfaceOrderedMap<K,V>- Specified by:
comparatorin 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:DebugWrites a developer readable, debug-formatted string representation of this object tooutput.
-
empty
public static <K,V,U> BTreeMap<K,V,U> empty()
-
-