Class RrbTree.ImRrbt<E>

    • Method Detail

      • makeNew

        @NotNull
        protected @NotNull RrbTree.ImRrbt<E> makeNew​(E @NotNull [] f,
                                                     int fi,
                                                     int fl,
                                                     @NotNull
                                                     @NotNull org.organicdesign.fp.collections.RrbTree.Node<E> r,
                                                     int s)
        Description copied from class: RrbTree
        Allows removing duplicated code by letting super-class produce new members of subclass types.
        Specified by:
        makeNew in class RrbTree<E>
      • append

        @NotNull
        public @NotNull RrbTree.ImRrbt<E> append​(E val)
        Returns a new BaseList with the additional item at the end.
        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 append
      • appendSome

        @Contract(pure=true)
        @NotNull
        public @NotNull RrbTree.ImRrbt<E> appendSome​(@NotNull
                                                     @NotNull Fn0<? extends @NotNull Option<E>> supplier)
        If supplier returns Some, return a new BaseList with the additional item at the end. If None, just return this BaseList unmodified.
        Specified by:
        appendSome in interface BaseList<E>
        Specified by:
        appendSome in interface ImList<E>
        Specified by:
        appendSome in class RrbTree<E>
        Parameters:
        supplier - return Option.Some to append, None for a no-op.
      • get

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

        @NotNull
        public @NotNull 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

        @NotNull
        public @NotNull RrbTree.ImRrbt<E> join​(@NotNull
                                               @NotNull 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.
        Overrides:
        join in class RrbTree<E>
      • replace

        @NotNull
        public @NotNull 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

        @NotNull
        public @NotNull 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 Collection<E>
        Specified by:
        size in interface List<E>
        Specified by:
        size in interface Sized
        Specified by:
        size in class RrbTree<E>
      • mt

        @NotNull
        protected @NotNull RrbTree.ImRrbt<E> mt()
        Description copied from class: RrbTree
        Creates a new empty ("M-T") tree of the appropriate (mutable/immutable) type.
        Specified by:
        mt in class RrbTree<E>
      • split

        @NotNull
        public @NotNull 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.
        Overrides:
        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

        @NotNull
        public @NotNull 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.