Package org.organicdesign.fp.collections
Interface BaseList<E>
-
- All Superinterfaces:
java.util.Collection<E>,java.lang.Iterable<E>,java.util.List<E>,Sized,Transformable<E>,UnmodCollection<E>,UnmodIterable<E>,UnmodList<E>,UnmodSortedCollection<E>,UnmodSortedIterable<E>
- All Known Subinterfaces:
ImList<E>,MutableList<E>
- All Known Implementing Classes:
PersistentVector,PersistentVector.MutableVector,RrbTree,RrbTree.ImRrbt,RrbTree.MutableRrbt
public interface BaseList<E> extends UnmodList<E>
Adds copy-on-write, "fluent interface" methods toUnmodList. Lowest common ancestor ofMutableListandImList.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodList
UnmodList.AbstractUnmodList<E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description BaseList<E>append(E e)Adds one item to the end of the ImList.BaseList<E>concat(java.lang.Iterable<? extends E> es)Efficiently adds items to the end of this ImList.default Eget(int i, E notFound)Returns the item at this index.default Option<E>head()The first item in this iterable.BaseList<E>replace(int idx, E e)Replace the item at the given index.BaseList<E>reverse()Returns a reversed copy of this list.-
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, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sort, subList, toArray, toArray
-
-
-
-
Method Detail
-
append
BaseList<E> append(E e)
Adds one item to the end of the ImList.- Parameters:
e- the value to insert- Returns:
- a new ImList with the additional item at the end.
-
concat
BaseList<E> concat(java.lang.Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.- Specified by:
concatin interfaceTransformable<E>- Specified by:
concatin interfaceUnmodIterable<E>- Parameters:
es- the values to insert- Returns:
- a new ImList with the additional items at the end.
-
get
default E get(int i, E notFound)
Returns the item at this index.- Parameters:
i- the zero-based index to get from the vector.notFound- the value to return if the index is out of bounds.- Returns:
- the value at that index, or the notFound value.
-
head
default Option<E> head()
The first item in this iterable.- Specified by:
headin interfaceTransformable<E>- Specified by:
headin interfaceUnmodIterable<E>- Returns:
- an eagerly evaluated result which is a single item.
-
replace
BaseList<E> replace(int idx, E e)
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.- Parameters:
idx- the index where the value should be stored.e- the value to store- Returns:
- a new ImList with the replaced item
-
-