Class RrbTree.MutRrbt<E>

java.lang.Object
org.pkl.core.util.paguro.RrbTree<E>
org.pkl.core.util.paguro.RrbTree.MutRrbt<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, org.organicdesign.fp.collections.BaseList<E>, org.organicdesign.fp.collections.MutList<E>, org.organicdesign.fp.collections.Sized, org.organicdesign.fp.collections.UnmodCollection<E>, org.organicdesign.fp.collections.UnmodIterable<E>, org.organicdesign.fp.collections.UnmodList<E>, org.organicdesign.fp.collections.UnmodSortedCollection<E>, org.organicdesign.fp.collections.UnmodSortedIterable<E>, org.organicdesign.fp.indent.Indented, org.organicdesign.fp.xform.Transformable<E>
Enclosing class:
RrbTree<E>

public static class RrbTree.MutRrbt<E> extends RrbTree<E> implements org.organicdesign.fp.collections.MutList<E>
Mutable version of an RrbTree. Timing information is available there.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.pkl.core.util.paguro.RrbTree

    RrbTree.ImRrbt<E>, RrbTree.MutRrbt<E>, RrbTree.Node<T>, RrbTree.SplitNode<T>

    Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodIterable

    org.organicdesign.fp.collections.UnmodIterable.UnIterable

    Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodList

    org.organicdesign.fp.collections.UnmodList.AbstractUnmodList<E>
  • Method Summary

    Modifier and Type
    Method
    Description
    append(E val)
    appendSome(org.organicdesign.fp.function.Fn0<? extends org.organicdesign.fp.oneOf.Option<E>> supplier)
    concat(@Nullable Iterable<? extends E> es)
    get(int i)
    indentedStr(int indent)
    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.
    org.organicdesign.fp.collections.UnmodSortedIterator<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.
    protected RrbTree.MutRrbt<E>
    makeNew(E[] f, int fi, int fl, RrbTree.Node<E> r, int s)
    Allows removing duplicated code by letting super-class produce new members of subclass types.
    protected RrbTree.MutRrbt<E>
    mt()
    Creates a new empty ("M-T") tree of the appropriate (mutable/immutable) type.
    precat(@Nullable Iterable<? extends E> es)
    Precat is implemented here because it is a very cheap operation on an RRB-Tree.
    replace(int index, E item)
    int
    org.organicdesign.fp.tuple.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.
    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).

    Methods inherited from class org.pkl.core.util.paguro.RrbTree

    empty, emptyMutable, equals, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.organicdesign.fp.collections.BaseList

    get, head

    Methods inherited from interface java.util.Collection

    parallelStream, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.List

    addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, reversed, spliterator

    Methods inherited from interface org.organicdesign.fp.collections.MutList

    add, addAll, reverse

    Methods inherited from interface org.organicdesign.fp.xform.Transformable

    any, toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutList, toMutMap, toMutRrbt, toMutSet, toMutSortedMap, toMutSortedSet

    Methods inherited from interface org.organicdesign.fp.collections.UnmodIterable

    drop, dropWhile, filter, flatMap, fold, foldUntil, map, take, takeWhile, whereNonNull

    Methods inherited from interface org.organicdesign.fp.collections.UnmodList

    add, addAll, clear, contains, containsAll, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sort, subList, toArray, toArray
  • Method Details

    • makeNew

      protected RrbTree.MutRrbt<E> makeNew(E[] f, int fi, int fl, 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

      public RrbTree.MutRrbt<E> append(E val)
      Specified by:
      append in interface org.organicdesign.fp.collections.BaseList<E>
      Specified by:
      append in interface org.organicdesign.fp.collections.MutList<E>
      Specified by:
      append in class RrbTree<E>
    • appendSome

      public RrbTree.MutRrbt<E> appendSome(org.organicdesign.fp.function.Fn0<? extends org.organicdesign.fp.oneOf.Option<E>> supplier)
      Specified by:
      appendSome in interface org.organicdesign.fp.collections.BaseList<E>
      Specified by:
      appendSome in interface org.organicdesign.fp.collections.MutList<E>
      Specified by:
      appendSome in class RrbTree<E>
    • concat

      public RrbTree.MutRrbt<E> concat(@Nullable @Nullable Iterable<? extends E> es)
      Specified by:
      concat in interface org.organicdesign.fp.collections.BaseList<E>
      Specified by:
      concat in interface org.organicdesign.fp.collections.MutList<E>
      Specified by:
      concat in interface org.organicdesign.fp.xform.Transformable<E>
      Specified by:
      concat in interface org.organicdesign.fp.collections.UnmodIterable<E>
    • precat

      public RrbTree.MutRrbt<E> precat(@Nullable @Nullable Iterable<? extends E> es)
      Precat is implemented here because it is a very cheap operation on an RRB-Tree. It's not implemented on PersistentVector because it is very expensive there.
      Specified by:
      precat in interface org.organicdesign.fp.xform.Transformable<E>
      Specified by:
      precat in interface org.organicdesign.fp.collections.UnmodIterable<E>
      Specified by:
      precat in class RrbTree<E>
    • get

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

      public RrbTree.ImRrbt<E> immutable()
      Specified by:
      immutable in interface org.organicdesign.fp.collections.MutList<E>
    • indentedStr

      public String indentedStr(int indent)
      Specified by:
      indentedStr in interface org.organicdesign.fp.indent.Indented
      Specified by:
      indentedStr in class RrbTree<E>
    • insert

      public 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.
    • iterator

      public org.organicdesign.fp.collections.UnmodSortedIterator<E> iterator()
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface List<E>
      Specified by:
      iterator in interface org.organicdesign.fp.collections.UnmodCollection<E>
      Specified by:
      iterator in interface org.organicdesign.fp.collections.UnmodIterable<E>
      Specified by:
      iterator in interface org.organicdesign.fp.collections.UnmodList<E>
      Specified by:
      iterator in interface org.organicdesign.fp.collections.UnmodSortedCollection<E>
      Specified by:
      iterator in interface org.organicdesign.fp.collections.UnmodSortedIterable<E>
      Specified by:
      iterator in class RrbTree<E>
    • toString

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

      public RrbTree.MutRrbt<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.
      Overrides:
      join in class RrbTree<E>
    • replace

      public RrbTree.MutRrbt<E> replace(int index, E item)
      Specified by:
      replace in interface org.organicdesign.fp.collections.BaseList<E>
      Specified by:
      replace in interface org.organicdesign.fp.collections.MutList<E>
      Specified by:
      replace in class RrbTree<E>
    • without

      public 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
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
      Specified by:
      size in interface org.organicdesign.fp.collections.Sized
      Specified by:
      size in class RrbTree<E>
    • mt

      protected 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

      public org.organicdesign.fp.tuple.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).