Class RrbTree.ImRrbt<E>

    • Method Detail

      • append

        public RrbTree.ImRrbt<E> append​(E val)
        Adds one item to the end of the ImList.
        Specified by:
        append in interface BaseList<E>
        Specified by:
        append in interface ImList<E>
        Specified by:
        append in class RrbTree<E>
        Parameters:
        val - the value to insert
        Returns:
        a new ImList with the additional item at the end.
      • concat

        public RrbTree.ImRrbt<E> concat​(java.lang.Iterable<? extends E> es)
        Efficiently adds items to the end of this ImList.
        Specified by:
        concat in interface BaseList<E>
        Specified by:
        concat in interface ImList<E>
        Specified by:
        concat in interface Transformable<E>
        Specified by:
        concat in interface UnmodIterable<E>
        Parameters:
        es - the values to insert
        Returns:
        a new ImList with the additional items at the end.
      • get

        public E get​(int i)
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class RrbTree<E>
      • insert

        public RrbTree.ImRrbt<E> insert​(int idx,
                                        E element)
        Inserts an item in the RRB tree pushing the current element at that index and all subsequent elements to the right.
        Specified by:
        insert in class RrbTree<E>
        Parameters:
        idx - the insertion point
        element - the item to insert
        Returns:
        a new RRB-Tree with the item inserted.
      • join

        public RrbTree<E> join​(RrbTree<E> that)
        Joins the given tree to the right side of this tree (or this to the left side of that one) in something like O(log n) time.
        Specified by:
        join in class RrbTree<E>
      • replace

        public RrbTree.ImRrbt<E> replace​(int index,
                                         E item)
        Replace the item at the given index. Note: i.replace(i.size(), o) used to be equivalent to i.concat(o), but it probably won't be for the RRB tree implementation, so this will change too.
        Specified by:
        replace in interface BaseList<E>
        Specified by:
        replace in interface ImList<E>
        Specified by:
        replace in class RrbTree<E>
        Parameters:
        index - the index where the value should be stored.
        item - the value to store
        Returns:
        a new ImList with the replaced item
      • without

        public RrbTree.ImRrbt<E> without​(int index)
        Returns a new RrbTree minus the given item (all items to the right are shifted left one) This is O(log n).
        Overrides:
        without in class RrbTree<E>
      • size

        public int size()
        Description copied from class: RrbTree
        Returns the number of items in this collection or iterable.
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
        Specified by:
        size in interface Sized
        Specified by:
        size in class RrbTree<E>
      • split

        public Tuple2<RrbTree.ImRrbt<E>,​RrbTree.ImRrbt<E>> split​(int splitIndex)
        Divides this RRB-Tree such that every index less-than the given index ends up in the left-hand tree and the indexed item and all subsequent ones end up in the right-hand tree.
        Specified by:
        split in class RrbTree<E>
        Parameters:
        splitIndex - the split point (excluded from the left-tree, included in the right one)
        Returns:
        two new sub-trees as determined by the split point. If the point is 0 or this.size() one tree will be empty (but never null).
      • indentedStr

        public java.lang.String indentedStr​(int indent)
        Returns a string where line breaks extend the given amount of indentation.
        Specified by:
        indentedStr in interface Indented
        Specified by:
        indentedStr in class RrbTree<E>
        Parameters:
        indent - the amount of indent to start at. Pretty-printed subsequent lines may have additional indent.
        Returns:
        a string with the given starting offset (in spaces) for every line.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object