Package org.organicdesign.fp.collections
Interface BaseList<E>
-
- All Superinterfaces:
Collection<E>
,Iterable<E>
,List<E>
,Sized
,Transformable<E>
,UnmodCollection<E>
,UnmodIterable<E>
,UnmodList<E>
,UnmodSortedCollection<E>
,UnmodSortedIterable<E>
- All Known Implementing Classes:
PersistentVector
,PersistentVector.MutVector
,RrbTree
,RrbTree.ImRrbt
,RrbTree.MutRrbt
public interface BaseList<E> extends UnmodList<E>
-
-
Nested Class Summary
-
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 Abstract Methods Default Methods Modifier and Type Method Description @NotNull BaseList<E>
append(E e)
Returns a new BaseList with the additional item at the end.default @NotNull BaseList<E>
appendSome(@NotNull Fn0<? extends @NotNull Option<E>> supplier)
If supplier returns Some, return a new BaseList with the additional item at the end.@NotNull BaseList<E>
concat(@Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.default E
get(int i, E notFound)
Returns the item at this index.default @NotNull Option<E>
head()
The first item in this iterable.@NotNull BaseList<E>
replace(int idx, E e)
Replace the item at the given index.@NotNull BaseList<E>
reverse()
Returns a reversed copy of this list.-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
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, 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
@NotNull @NotNull BaseList<E> append(E e)
Returns a new BaseList with the additional item at the end.- Parameters:
e
- the value to append
-
appendSome
@NotNull default @NotNull BaseList<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.- Parameters:
supplier
- returnOption.Some
to append,None
for a no-op.
-
concat
@NotNull @NotNull BaseList<E> concat(@Nullable @Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.- Specified by:
concat
in interfaceTransformable<E>
- Specified by:
concat
in 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
@NotNull default @NotNull Option<E> head()
The first item in this iterable.- Specified by:
head
in interfaceTransformable<E>
- Specified by:
head
in interfaceUnmodIterable<E>
- Returns:
- an eagerly evaluated result which is a single item.
-
replace
@NotNull @NotNull 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
-
-