Package org.organicdesign.fp.collections
Interface MutList<E>
-
- All Superinterfaces:
BaseList<E>
,Collection<E>
,Iterable<E>
,List<E>
,Sized
,Transformable<E>
,UnmodCollection<E>
,UnmodIterable<E>
,UnmodList<E>
,UnmodSortedCollection<E>
,UnmodSortedIterable<E>
- All Known Implementing Classes:
PersistentVector.MutVector
,RrbTree.MutRrbt
public interface MutList<E> extends BaseList<E>
A mutate-in-place interface using the same copy-on-write methods asBaseList
andImList
so that you can treat mutable and immutable lists the same. You could think of this as a builder for an ImList, or just a stand-alone MutList that behaves similarly (extendsTransformable
). Being mutable, this is inherently NOT thread-safe.
-
-
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 default boolean
add(E val)
Ensures that this collection contains the specified element (optional operation).default boolean
addAll(@NotNull Collection<? extends E> c)
Appends all the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.@NotNull MutList<E>
append(E val)
Adds one item to the end of the ImList.default @NotNull MutList<E>
appendWhen(@NotNull Fn0<Boolean> test, E e)
Adds one item to the end of the ImList.default @NotNull MutList<E>
concat(@Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.ImList<E>
immutable()
Returns a immutable version of this mutable list.@NotNull MutList<E>
replace(int idx, E e)
Replace the item at the given index.default @NotNull MutList<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, addAll, clear, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, sort, subList, toArray, toArray
-
-
-
-
Method Detail
-
appendWhen
@NotNull default @NotNull MutList<E> appendWhen(@NotNull @NotNull Fn0<Boolean> test, E e)
Adds one item to the end of the ImList.- Specified by:
appendWhen
in interfaceBaseList<E>
e
- the value to insert- Returns:
- a new ImList with the additional item at the end.
-
add
default boolean add(E val)
Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call.
-
addAll
default boolean addAll(@NotNull @NotNull Collection<? extends E> c)
Appends all the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
-
concat
@NotNull default @NotNull MutList<E> concat(@Nullable @Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.- Specified by:
concat
in interfaceBaseList<E>
- 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.
-
replace
@NotNull @NotNull MutList<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.
-
-