Class Lists
List
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <A> List
<A> Returns a list that is a view of two other list concatenated.static <A,
B> List <B> Returns a list that is a view of another list with each element transformed by a function.static <A> List
<A> Returns a list that is a view of another list with the element order reversed.static <A> List
<A> snapshot
(Collection<? extends A> elems) Makes a copy of the current content of a collection.static <A,
B, C> List <C> zip
(BiFunction<? super A, ? super B, ? extends C> fun, List<? extends A> left, List<? extends B> right) Returns a list that is a view of two other list with each pair of elements combined by a function.
-
Method Details
-
reverse
Returns a list that is a view of another list with the element order reversed.Changes to the underlying list are visible through the reversed list, and vice versa.
- Parameters:
list
- a list- Returns:
- a list that has the same elements as the given list, but in opposite order
-
snapshot
Makes a copy of the current content of a collection.The copy is an immutable list, and contains all elements that the given collection currently contains, in the order they would be returned by an
Iterator
.Subsequent changes to the given collection will not be reflected in the copy.
- Parameters:
elems
- a collection- Returns:
- a list that has the same elements as the given collection currently has, in the order of iteration
-
map
Returns a list that is a view of another list with each element transformed by a function.Changes to the underlying list are visible through the transformed list, but not vice versa; the transformed list is unmodifiable.
The transformed elements are not stored in memory; they are computed anew on every access. This is only efficient if the transforming function is cheap, or if the list is iterated just once. For reusable transformed lists, consider making a
snapshot
.- Parameters:
fun
- the element transformer functionelems
- the list to be transformed- See Also:
-
concat
Returns a list that is a view of two other list concatenated.Changes to the underlying lists are visible through the concatenated list, but not vice versa; the concatenated list is unmodifiable.
The concatenated elements are not stored contigously in memory; which part an element comes from is determined on every access. This is only efficient if concatenation is not nested too deeply. For quick-access concatenated lists, consider making a
snapshot
.- Parameters:
first
- the first list to concatenatesecond
- the second list to concatenate- Returns:
- a list that contains the elements of the first list followed by the elements of the second list
-
zip
public static <A,B, List<C> zipC> (BiFunction<? super A, ? super B, ? extends C> fun, List<? extends A> left, List<? extends B> right) Returns a list that is a view of two other list with each pair of elements combined by a function.Changes to the underlying lists are visible through the combined list, but not vice versa; the combined list is unmodifiable.
The combined elements are not stored in memory; they are computed anew on every access. This is only efficient if the combining function is cheap, or if the list is iterated just once. For reusable combined lists, consider making a
snapshot
.- Parameters:
fun
- the element combiner functionleft
- one list to be combinedright
- the other list to be combined- Throws:
IllegalArgumentException
- if the two given lists are of different sizes- See Also:
-