public interface UnmodList<E> extends List<E>, UnmodSortedCollection<E>
Collections.unmodifiableList(List), deprecating
mutator methods and implementing them to throw exceptions. You could think of this as
"clearing the slate" to a point where immutable, functional, fluent interfaces can be built again.| Modifier and Type | Interface and Description |
|---|---|
static class |
UnmodList.AbstractUnmodList<E>
Implements equals and hashCode() methods compatible with java.util.List (which ignores order)
to make defining unmod lists easier.
|
| Modifier and Type | Method and Description |
|---|---|
default boolean |
add(E e)
Deprecated.
|
default void |
add(int index,
E element)
Deprecated.
|
default boolean |
addAll(Collection<? extends E> c)
Deprecated.
|
default boolean |
addAll(int index,
Collection<? extends E> c)
Deprecated.
|
default void |
clear()
Deprecated.
|
default boolean |
contains(Object o)
Deprecated.
|
default boolean |
containsAll(Collection<?> c)
The default implementation of this method has O(this.size() + that.size()) or O(n) performance.
|
default int |
indexOf(Object o)
The default implementation of this method has O(this.size()) performance.
|
default boolean |
isEmpty()
A convenience method to check if size is 0
|
default UnmodSortedIterator<E> |
iterator()
A convenience method to get a listIterator.
|
default int |
lastIndexOf(Object o)
The default implementation of this method has O(this.size()) performance.
|
default UnmodListIterator<E> |
listIterator() |
default UnmodListIterator<E> |
listIterator(int index)
Subclasses should override this when they can do so more efficiently.
|
static <T> void |
permutations(List<T> items,
Fn2<? super T,? super T,?> f)
Apply the given function against all unique pairings of items in the list.
|
default E |
remove(int index)
Deprecated.
|
default boolean |
remove(Object o)
Deprecated.
|
default boolean |
removeAll(Collection<?> c)
Deprecated.
|
default boolean |
removeIf(Predicate<? super E> filter)
Deprecated.
|
default void |
replaceAll(UnaryOperator<E> operator)
Deprecated.
|
default boolean |
retainAll(Collection<?> c)
Deprecated.
|
default E |
set(int index,
E element)
Deprecated.
|
default void |
sort(Comparator<? super E> c)
Deprecated.
|
default UnmodList<E> |
subList(int fromIndex,
int toIndex) |
default Object[] |
toArray()
This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for
backwards compatibility in some performance-critical situations.
|
default <T> T[] |
toArray(T[] as)
This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for
backwards compatibility in some performance-critical situations.
|
parallelStream, streamcastFromList, castFromSortedMap, castFromSortedSet, equalconcat, drop, dropWhile, filter, flatMap, fold, foldUntil, hash, head, map, precat, take, takeWhile, toStringtoImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSetstatic <T> void permutations(List<T> items, Fn2<? super T,? super T,?> f)
@Deprecated default boolean add(E e)
add in interface Collection<E>add in interface List<E>add in interface UnmodCollection<E>@Deprecated default void add(int index, E element)
@Deprecated default boolean addAll(Collection<? extends E> c)
addAll in interface Collection<E>addAll in interface List<E>addAll in interface UnmodCollection<E>@Deprecated default boolean addAll(int index, Collection<? extends E> c)
@Deprecated default void clear()
clear in interface Collection<E>clear in interface List<E>clear in interface UnmodCollection<E>@Deprecated default boolean contains(Object o)
default boolean containsAll(Collection<?> c)
containsAll in interface Collection<E>containsAll in interface List<E>containsAll in interface UnmodCollection<E>default int indexOf(Object o)
default boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>isEmpty in interface UnmodCollection<E>default UnmodSortedIterator<E> iterator()
iterator in interface Collection<E>iterator in interface Iterable<E>iterator in interface List<E>iterator in interface UnmodCollection<E>iterator in interface UnmodIterable<E>iterator in interface UnmodSortedCollection<E>iterator in interface UnmodSortedIterable<E>default int lastIndexOf(Object o)
lastIndexOf in interface List<E>default UnmodListIterator<E> listIterator()
listIterator in interface List<E>default UnmodListIterator<E> listIterator(int index)
listIterator in interface List<E>@Deprecated default E remove(int index)
@Deprecated default boolean remove(Object o)
remove in interface Collection<E>remove in interface List<E>remove in interface UnmodCollection<E>@Deprecated default boolean removeAll(Collection<?> c)
removeAll in interface Collection<E>removeAll in interface List<E>removeAll in interface UnmodCollection<E>@Deprecated default void replaceAll(UnaryOperator<E> operator)
replaceAll in interface List<E>@Deprecated default boolean retainAll(Collection<?> c)
retainAll in interface Collection<E>retainAll in interface List<E>retainAll in interface UnmodCollection<E>@Deprecated default E set(int index, E element)
@Deprecated default void sort(Comparator<? super E> c)
default Object[] toArray()
toArray in interface Collection<E>toArray in interface List<E>toArray in interface UnmodCollection<E>default <T> T[] toArray(T[] as)
MyThing[] things = col.toArray(new MyThing[coll.size()]);
Calling this method any other way causes unnecessary work to be done - an extra memory
allocation and potential garbage collection if the passed array is too small, extra effort to
fill the end of the array with nulls if it is too large.
This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards
compatibility in some performance-critical situations. If you need to create an array (you almost always do)
then the best way to use this method is:
MyThing[] things = col.toArray(new MyThing[coll.size()]);
Calling this method any other way causes unnecessary work to be done - an extra memory allocation and potential
garbage collection if the passed array is too small, extra effort to fill the end of the array with nulls if it
is too large.
toArray in interface Collection<E>toArray in interface List<E>toArray in interface UnmodCollection<E>@Deprecated default boolean removeIf(Predicate<? super E> filter)
removeIf in interface Collection<E>removeIf in interface UnmodCollection<E>Copyright © 2019. All rights reserved.