Class BTree<K,V>

java.lang.Object
swim.collections.BTreeContext<K,V>
swim.collections.BTree<K,V>
All Implemented Interfaces:
Iterable<Map.Entry<K,V>>, Map<K,V>, SortedMap<K,V>, swim.codec.Debug, swim.util.IterableMap<K,V>, swim.util.OrderedMap<K,V>

public class BTree<K,V> extends BTreeContext<K,V> implements swim.util.OrderedMap<K,V>, swim.codec.Debug
Immutable OrderedMap backed by a B-tree.
  • Constructor Details

  • Method Details

    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface swim.util.IterableMap<K,V>
      Specified by:
      isEmpty in interface Map<K,V>
      Specified by:
      isEmpty in interface swim.util.OrderedMap<K,V>
    • size

      public int size()
      Specified by:
      size in interface swim.util.IterableMap<K,V>
      Specified by:
      size in interface Map<K,V>
      Specified by:
      size in interface swim.util.OrderedMap<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface swim.util.IterableMap<K,V>
      Specified by:
      containsKey in interface Map<K,V>
      Specified by:
      containsKey in interface swim.util.OrderedMap<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface swim.util.IterableMap<K,V>
      Specified by:
      containsValue in interface Map<K,V>
      Specified by:
      containsValue in interface swim.util.OrderedMap<K,V>
    • indexOf

      public int indexOf(Object key)
      Specified by:
      indexOf in interface swim.util.OrderedMap<K,V>
    • get

      public V get(Object key)
      Specified by:
      get in interface swim.util.IterableMap<K,V>
      Specified by:
      get in interface Map<K,V>
      Specified by:
      get in interface swim.util.OrderedMap<K,V>
    • getEntry

      public Map.Entry<K,V> getEntry(Object key)
      Specified by:
      getEntry in interface swim.util.OrderedMap<K,V>
    • getIndex

      public Map.Entry<K,V> getIndex(int index)
      Specified by:
      getIndex in interface swim.util.OrderedMap<K,V>
    • firstEntry

      public Map.Entry<K,V> firstEntry()
      Specified by:
      firstEntry in interface swim.util.OrderedMap<K,V>
    • firstKey

      public K firstKey()
      Specified by:
      firstKey in interface swim.util.OrderedMap<K,V>
      Specified by:
      firstKey in interface SortedMap<K,V>
    • firstValue

      public V firstValue()
      Specified by:
      firstValue in interface swim.util.OrderedMap<K,V>
    • lastEntry

      public Map.Entry<K,V> lastEntry()
      Specified by:
      lastEntry in interface swim.util.OrderedMap<K,V>
    • lastKey

      public K lastKey()
      Specified by:
      lastKey in interface swim.util.OrderedMap<K,V>
      Specified by:
      lastKey in interface SortedMap<K,V>
    • lastValue

      public V lastValue()
      Specified by:
      lastValue in interface swim.util.OrderedMap<K,V>
    • nextEntry

      public Map.Entry<K,V> nextEntry(K key)
      Specified by:
      nextEntry in interface swim.util.OrderedMap<K,V>
    • nextKey

      public K nextKey(K key)
      Specified by:
      nextKey in interface swim.util.OrderedMap<K,V>
    • nextValue

      public V nextValue(K key)
      Specified by:
      nextValue in interface swim.util.OrderedMap<K,V>
    • previousEntry

      public Map.Entry<K,V> previousEntry(K key)
      Specified by:
      previousEntry in interface swim.util.OrderedMap<K,V>
    • previousKey

      public K previousKey(K key)
      Specified by:
      previousKey in interface swim.util.OrderedMap<K,V>
    • previousValue

      public V previousValue(K key)
      Specified by:
      previousValue in interface swim.util.OrderedMap<K,V>
    • put

      public V put(K key, V newValue)
      Specified by:
      put in interface swim.util.IterableMap<K,V>
      Specified by:
      put in interface Map<K,V>
      Specified by:
      put in interface swim.util.OrderedMap<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> map)
      Specified by:
      putAll in interface swim.util.IterableMap<K,V>
      Specified by:
      putAll in interface Map<K,V>
      Specified by:
      putAll in interface swim.util.OrderedMap<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface swim.util.IterableMap<K,V>
      Specified by:
      remove in interface Map<K,V>
      Specified by:
      remove in interface swim.util.OrderedMap<K,V>
    • drop

      public BTree<K,V> drop(int lower)
    • take

      public BTree<K,V> take(int upper)
    • clear

      public void clear()
      Specified by:
      clear in interface swim.util.IterableMap<K,V>
      Specified by:
      clear in interface Map<K,V>
      Specified by:
      clear in interface swim.util.OrderedMap<K,V>
    • updated

      public BTree<K,V> updated(K key, V newValue)
    • removed

      public BTree<K,V> removed(K key)
    • cleared

      public BTree<K,V> cleared()
    • iterator

      public swim.util.OrderedMapCursor<K,V> iterator()
      Specified by:
      iterator in interface Iterable<K>
      Specified by:
      iterator in interface swim.util.IterableMap<K,V>
      Specified by:
      iterator in interface swim.util.OrderedMap<K,V>
    • keyIterator

      public swim.util.Cursor<K> keyIterator()
      Specified by:
      keyIterator in interface swim.util.IterableMap<K,V>
      Specified by:
      keyIterator in interface swim.util.OrderedMap<K,V>
    • valueIterator

      public swim.util.Cursor<V> valueIterator()
      Specified by:
      valueIterator in interface swim.util.IterableMap<K,V>
      Specified by:
      valueIterator in interface swim.util.OrderedMap<K,V>
    • reverseIterator

      public swim.util.OrderedMapCursor<K,V> reverseIterator()
    • reverseKeyIterator

      public swim.util.Cursor<K> reverseKeyIterator()
    • reverseValueIterator

      public swim.util.Cursor<V> reverseValueIterator()
    • copy

      protected BTree<K,V> copy(BTreePage<K,V,?> root)
    • comparator

      public Comparator<? super K> comparator()
      Specified by:
      comparator in interface swim.util.OrderedMap<K,V>
      Specified by:
      comparator in interface SortedMap<K,V>
    • equals

      public boolean equals(Object other)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • debug

      public <T> swim.codec.Output<T> debug(swim.codec.Output<T> output)
      Specified by:
      debug in interface swim.codec.Debug
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • empty

      public static <K, V> BTree<K,V> empty()
    • from

      public static <K, V> BTree<K,V> from(Map<? extends K,? extends V> map)