Package org.organicdesign.fp.collections
Class RrbTree.MutRrbt<E>
- java.lang.Object
-
- org.organicdesign.fp.collections.RrbTree<E>
-
- org.organicdesign.fp.collections.RrbTree.MutRrbt<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
,BaseList<E>
,MutList<E>
,Sized
,UnmodCollection<E>
,UnmodIterable<E>
,UnmodList<E>
,UnmodSortedCollection<E>
,UnmodSortedIterable<E>
,Indented
,Transformable<E>
public static class RrbTree.MutRrbt<E> extends RrbTree<E> implements MutList<E>
Mutable version of anRrbTree
. Timing information is available there.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.organicdesign.fp.collections.RrbTree
RrbTree.ImRrbt<E>, RrbTree.MutRrbt<E>
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodIterable
UnmodIterable.UnIterable
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodList
UnmodList.AbstractUnmodList<E>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull RrbTree.MutRrbt<E>
append(E val)
Adds one item to the end of the ImList.@NotNull RrbTree.MutRrbt<E>
appendWhen(@NotNull Fn0<Boolean> test, E e)
Adds one item to the end of the ImList.@NotNull RrbTree.MutRrbt<E>
concat(@Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.E
get(int i)
@NotNull RrbTree.ImRrbt<E>
immutable()
Returns a immutable version of this mutable list.@NotNull String
indentedStr(int indent)
Returns a string where line breaks extend the given amount of indentation.@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.@NotNull UnmodSortedIterator<E>
iterator()
A convenience method to get a listIterator.@NotNull RrbTree.MutRrbt<E>
join(@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.protected @NotNull RrbTree.MutRrbt<E>
makeNew(E @NotNull [] f, int fi, int fl, @NotNull org.organicdesign.fp.collections.RrbTree.Node<E> r, int s)
Allows removing duplicated code by letting super-class produce new members of subclass types.protected @NotNull RrbTree.MutRrbt<E>
mt()
Creates a new empty ("M-T") tree of the appropriate (mutable/immutable) type.@NotNull RrbTree.MutRrbt<E>
replace(int index, E item)
Replace the item at the given index.int
size()
Returns the number of items in this collection or iterable.@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.@NotNull String
toString()
@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).-
Methods inherited from class org.organicdesign.fp.collections.RrbTree
empty, emptyMutable, equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
equals, hashCode, spliterator
-
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, precat, 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 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.
-
append
@NotNull public @NotNull RrbTree.MutRrbt<E> append(E val)
Adds one item to the end of the ImList.
-
appendWhen
@NotNull public @NotNull RrbTree.MutRrbt<E> appendWhen(@NotNull @NotNull Fn0<Boolean> test, E e)
Adds one item to the end of the ImList.- Specified by:
appendWhen
in interfaceBaseList<E>
- Specified by:
appendWhen
in interfaceMutList<E>
- Specified by:
appendWhen
in classRrbTree<E>
e
- the value to insert- Returns:
- a new ImList with the additional item at the end.
-
concat
@NotNull public @NotNull RrbTree.MutRrbt<E> concat(@Nullable @Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.
-
get
public E get(int i)
-
immutable
@NotNull public @NotNull RrbTree.ImRrbt<E> immutable()
Returns a immutable version of this mutable list.
-
indentedStr
@NotNull public @NotNull String indentedStr(int indent)
Returns a string where line breaks extend the given amount of indentation.- Specified by:
indentedStr
in interfaceIndented
- Specified by:
indentedStr
in classRrbTree<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
@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.
-
iterator
@NotNull public @NotNull UnmodSortedIterator<E> iterator()
A convenience method to get a listIterator.- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in interfaceList<E>
- Specified by:
iterator
in interfaceUnmodCollection<E>
- Specified by:
iterator
in interfaceUnmodIterable<E>
- Specified by:
iterator
in interfaceUnmodList<E>
- Specified by:
iterator
in interfaceUnmodSortedCollection<E>
- Specified by:
iterator
in interfaceUnmodSortedIterable<E>
- Specified by:
iterator
in classRrbTree<E>
-
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.
-
replace
@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.
-
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).
-
size
public int size()
Description copied from class:RrbTree
Returns the number of items in this collection or iterable.
-
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.
-
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.
-
-