T - The type of the elements of this list.F - The type of the elements of the backing list.public class ListTransformOnceView<F,T>
extends java.util.AbstractList<T>
List which will be automatically updated along with the
original, but whose elements will be a transformation of the original
associated elements by way of the function passed to the constructor. The
implementation employs lazy evaluation, and only evaluates a transformation
once for each element of the collection, as distinguished by identity.
Unlike the Stream.map(Function) function, which can provide similar
functionality in certain circumstances, this class provides a view which is
reusable and backed by the original collection, such that it will reflect
changes.
If the constructor is supplied with an InvertibleFunction, it will be
possible to add elements to this collection.
| Constructor and Description |
|---|
ListTransformOnceView(java.util.List<F> backingCollection,
java.util.function.Function<? super F,? extends T> function) |
ListTransformOnceView(java.util.List<F> backingCollection,
InvertibleFunction<F,T> function) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element) |
T |
get(int index) |
java.util.List<F> |
getBackingList() |
java.util.function.Function<F,T> |
getFunction() |
T |
remove(int index) |
T |
set(int index,
T element) |
int |
size() |
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic ListTransformOnceView(java.util.List<F> backingCollection, java.util.function.Function<? super F,? extends T> function)
backingCollection - The backing collection this class presents a view over.function - The function which transforms elements into the form in which they
are represented in by this view.public ListTransformOnceView(java.util.List<F> backingCollection, InvertibleFunction<F,T> function)
backingCollection - The backing collection this class presents a view over.function - The function which transforms elements into the form in which they
are represented in by this view.public void add(int index,
T element)
public T remove(int index)
public final T get(int index)
public final java.util.List<F> getBackingList()
public final java.util.function.Function<F,T> getFunction()