Package org.organicdesign.fp.collections
Class RrbTree.ImRrbt<E>
- java.lang.Object
-
- org.organicdesign.fp.collections.RrbTree<E>
-
- org.organicdesign.fp.collections.RrbTree.ImRrbt<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,BaseList<E>
,ImList<E>
,Sized
,UnmodCollection<E>
,UnmodIterable<E>
,UnmodList<E>
,UnmodSortedCollection<E>
,UnmodSortedIterable<E>
,Indented
,Transformable<E>
public static class RrbTree.ImRrbt<E> extends RrbTree<E> implements ImList<E>, java.io.Serializable
Immutable version of anRrbTree
. Timing information is available there.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.organicdesign.fp.collections.RrbTree
RrbTree.ImRrbt<E>, RrbTree.MutableRrbt<E>
-
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 RrbTree.ImRrbt<E>
append(E val)
Adds one item to the end of the ImList.RrbTree.ImRrbt<E>
concat(java.lang.Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.E
get(int i)
java.lang.String
indentedStr(int indent)
Returns a string where line breaks extend the given amount of indentation.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.UnmodSortedIterator<E>
iterator()
A convenience method to get a listIterator.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.RrbTree.MutableRrbt<E>
mutable()
Returns a mutable list (builder)RrbTree.ImRrbt<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.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.java.lang.String
toString()
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).-
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 org.organicdesign.fp.xform.Transformable
toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSet
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodIterable
drop, dropWhile, filter, flatMap, fold, foldUntil, map, precat, take, takeWhile
-
Methods inherited from interface org.organicdesign.fp.collections.UnmodList
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sort, subList, toArray, toArray
-
-
-
-
Method Detail
-
append
public RrbTree.ImRrbt<E> append(E val)
Adds one item to the end of the ImList.
-
concat
public RrbTree.ImRrbt<E> concat(java.lang.Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.
-
get
public E get(int i)
-
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.
-
mutable
public RrbTree.MutableRrbt<E> mutable()
Returns a mutable list (builder)
-
iterator
public UnmodSortedIterator<E> iterator()
A convenience method to get a listIterator.- Specified by:
iterator
in interfacejava.util.Collection<E>
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
- Specified by:
iterator
in interfacejava.util.List<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
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.
-
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.
-
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).
-
size
public int size()
Description copied from class:RrbTree
Returns the number of items in this collection or iterable.
-
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.
-
indentedStr
public java.lang.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.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-