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 asBaseListandImListso 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 booleanadd(E val)Ensures that this collection contains the specified element (optional operation).default booleanaddAll(@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 e)Adds the item to the end of this list (mutating it in place).default @NotNull MutList<E>appendSome(@NotNull Fn0<? extends @NotNull Option<E>> supplier)If supplier returns Some, append the additional item to the end of this MutList (modifying it in place).default @NotNull MutList<E>concat(@Nullable Iterable<? extends E> es)Efficiently adds items to the end of this ImList.ImList<E>immutable()Returns an 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
-
append
@Contract(mutates="this") @NotNull @NotNull MutList<E> append(E e)
Adds the item to the end of this list (mutating it in place).
-
appendSome
@Contract(mutates="this") @NotNull default @NotNull MutList<E> appendSome(@NotNull @NotNull Fn0<? extends @NotNull Option<E>> supplier)
If supplier returns Some, append the additional item to the end of this MutList (modifying it in place). If None, just return this MutList unmodified.- Specified by:
appendSomein interfaceBaseList<E>- Parameters:
supplier- returnOption.Someto append,Nonefor a no-op.
-
add
@Contract(mutates="this") 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
@Contract(mutates="this") 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
@Contract(mutates="this") @NotNull default @NotNull MutList<E> concat(@Nullable @Nullable Iterable<? extends E> es)
Efficiently adds items to the end of this ImList.- Specified by:
concatin interfaceBaseList<E>- 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.
-
replace
@Contract(mutates="this") @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.
-
-