Class BTreeMap<K,​V,​U>

  • All Implemented Interfaces:
    Cloneable, Iterable<Map.Entry<K,​V>>, Map<K,​V>, SortedMap<K,​V>, swim.codec.Debug, swim.util.IterableMap<K,​V>, swim.util.OrderedMap<K,​V>, swim.util.ReducedMap<K,​V,​U>

    public class BTreeMap<K,​V,​U>
    extends BTreeContext<K,​V>
    implements swim.util.ReducedMap<K,​V,​U>, Cloneable, swim.codec.Debug
    Mutable, thread-safe Map backed by a B-tree.
    • Constructor Detail

      • BTreeMap

        protected BTreeMap​(BTreePage<K,​V,​U> root)
      • BTreeMap

        public BTreeMap()
    • Method Detail

      • 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 BTreeMap<K,​V,​U> drop​(int lower)
      • take

        public BTreeMap<K,​V,​U> 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 BTreeMap<K,​V,​U> updated​(K key,
                                                   V newValue)
      • reduced

        public U reduced​(U identity,
                         swim.util.CombinerFunction<? super V,​U> accumulator,
                         swim.util.CombinerFunction<U,​U> combiner)
        Specified by:
        reduced in interface swim.util.ReducedMap<K,​V,​U>
      • snapshot

        public BTree<K,​V> snapshot()
        An immutable copy of this BTreeMap's data.
      • 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>
      • lastIterator

        public swim.util.OrderedMapCursor<K,​V> lastIterator()
      • lastKeyIterator

        public swim.util.Cursor<K> lastKeyIterator()
      • lastValueIterator

        public swim.util.Cursor<V> lastValueIterator()
      • comparator

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

        public void debug​(swim.codec.Output<?> output)
        Specified by:
        debug in interface swim.codec.Debug
      • empty

        public static <K,​V,​U> BTreeMap<K,​V,​U> empty()
      • of

        public static <K,​V,​U> BTreeMap<K,​V,​U> of​(K key,
                                                                         V value)
      • from

        public static <K,​V,​U> BTreeMap<K,​V,​U> from​(Map<? extends K,​? extends V> map)