Class RrbTree.MutRrbt<E>

    • Method Detail

      • makeNew

        @NotNull
        protected @NotNull RrbTree.MutRrbt<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

        @Contract(mutates="this")
        @NotNull
        public @NotNull RrbTree.MutRrbt<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 MutList<E>
        Specified by:
        append in class RrbTree<E>
        Parameters:
        val - the value to append
      • appendSome

        @Contract(mutates="this")
        @NotNull
        public @NotNull RrbTree.MutRrbt<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 MutList<E>
        Specified by:
        appendSome in class RrbTree<E>
        Parameters:
        supplier - return Option.Some to append, None for a no-op.
      • concat

        @Contract(mutates="this")
        @NotNull
        public @NotNull RrbTree.MutRrbt<E> concat​(@Nullable
                                                  @Nullable 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 MutList<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 List<E>
        Specified by:
        get in class RrbTree<E>
      • immutable

        @NotNull
        public @NotNull RrbTree.ImRrbt<E> immutable()
        Returns an immutable version of this mutable list.
        Specified by:
        immutable in interface MutList<E>
      • 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.
      • insert

        @Contract(mutates="this")
        @NotNull
        public @NotNull RrbTree.MutRrbt<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.MutRrbt<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

        @Contract(mutates="this")
        @NotNull
        public @NotNull RrbTree.MutRrbt<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 MutList<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.MutRrbt<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.MutRrbt<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.MutRrbt<E>,​RrbTree.MutRrbt<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).