Class ManifoldListCollectionExt
- java.lang.Object
-
- manifold.collections.extensions.java.util.List.ManifoldListCollectionExt
-
public class ManifoldListCollectionExt extends Object
-
-
Constructor Summary
Constructors Constructor Description ManifoldListCollectionExt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> Efirst(List<E> thiz)Returns first element.static <E> EfirstOrNull(List<E> thiz)Returns the first element, or null if the list is empty.static <E> EgetOrNull(List<E> thiz, int index)Returns an element at the givenindexor null if theindexis out of bounds of this list.static <E> Elast(List<E> thiz)Returns the last element.static <E> Elast(List<E> thiz, Predicate<E> predicate)Returns the last element matching the givenpredicate.static <E> ElastOrNull(List<E> thiz)Returns the last element, ornullif the list is empty.static <E> ElastOrNull(List<E> thiz, Predicate<E> predicate)Returns the last element matching the givenpredicate, ornullif no such element was found.static <E> List<E>optimizeReadOnlyList(List<E> thiz)static <E> voidreverse(List<E> thiz)Reverses elements in the list in-place.static <E> Esingle(List<E> thiz)Returns the single element, or throws an exception if the list is empty or has more than one element.static <E> EsingleOrNull(List<E> thiz)Returns single element, ornullif the list is empty or has more than one element.
-
-
-
Method Detail
-
first
public static <E> E first(List<E> thiz)
Returns first element.- Throws:
NoSuchElementException- if the list is empty.
-
firstOrNull
public static <E> E firstOrNull(List<E> thiz)
Returns the first element, or null if the list is empty.
-
last
public static <E> E last(List<E> thiz)
Returns the last element.- Throws:
NoSuchElementException- if the list is empty.
-
last
public static <E> E last(List<E> thiz, Predicate<E> predicate)
Returns the last element matching the givenpredicate.- Throws:
NoSuchElementException- if no such element is found.
-
lastOrNull
public static <E> E lastOrNull(List<E> thiz)
Returns the last element, ornullif the list is empty.
-
lastOrNull
public static <E> E lastOrNull(List<E> thiz, Predicate<E> predicate)
Returns the last element matching the givenpredicate, ornullif no such element was found.
-
single
public static <E> E single(List<E> thiz)
Returns the single element, or throws an exception if the list is empty or has more than one element.
-
singleOrNull
public static <E> E singleOrNull(List<E> thiz)
Returns single element, ornullif the list is empty or has more than one element.
-
getOrNull
public static <E> E getOrNull(List<E> thiz, int index)
Returns an element at the givenindexor null if theindexis out of bounds of this list.
-
reverse
public static <E> void reverse(List<E> thiz)
Reverses elements in the list in-place.
-
-