Contents
Class ListUtil
java.lang.Object
com.hypixel.hytale.common.util.ListUtil
- Since:
- 07/11/2017
- Version:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,V> int binarySearch(List<? extends T> l, Function<T, V> func, V key, Comparator<? super V> c) static <T> booleanemptyOrAllNull(List<T> list) static <T,U> void removeIf(List<T> list, BiPredicate<T, U> predicate, U obj) static <T> voidstatic <T,U, V> void unstableRemoveIf(List<T> list, U obj1, V obj2, TriPredicate<T, U, V> predicate) Removes predicate-matching elements from the given list by swapping them with the last element in the list and then popping the last element to trim the list by one.static <T,U, V, W> void unstableRemoveIf(List<T> list, U obj1, V obj2, W obj3, QuadPredicate<T, U, V, W> predicate) Removes predicate-matching elements from the given list by swapping them with the last element in the list and then popping the last element to trim the list by one.
-
Constructor Details
-
ListUtil
public ListUtil()
-
-
Method Details
-
partition
-
removeIf
-
removeIf
public static <T,U> void removeIf(@Nonnull List<T> list, @Nonnull BiPredicate<T, U> predicate, U obj) -
unstableRemoveIf
public static <T,U, void unstableRemoveIfV> (@Nonnull List<T> list, @Nullable U obj1, @Nullable V obj2, @Nonnull TriPredicate<T, U, V> predicate) Removes predicate-matching elements from the given list by swapping them with the last element in the list and then popping the last element to trim the list by one. This approach can be much more efficient than standard removal operations as it eliminates the need to shift elements forward in the list each time one is removed from the front or middle. This does, however, result in the ordering of elements becoming unstable so may not be suitable where element order is still important.- Type Parameters:
T- the type of the elements in the list.U- the type of the first object used for predicate evaluation.V- the type of the second object used for predicate evaluation.- Parameters:
list- the list from which elements will be removed; must not be null.obj1- an optional object passed to the predicate for condition evaluation; may be null.obj2- an optional object passed to the predicate for condition evaluation; may be null.predicate- the condition used to determine whether an element should be removed; must not be null.
-
unstableRemoveIf
public static <T,U, void unstableRemoveIfV, W> (@Nonnull List<T> list, @Nullable U obj1, @Nullable V obj2, @Nullable W obj3, @Nonnull QuadPredicate<T, U, V, W> predicate) Removes predicate-matching elements from the given list by swapping them with the last element in the list and then popping the last element to trim the list by one. This approach can be much more efficient than standard removal operations as it eliminates the need to shift elements forward in the list each time one is removed from the front or middle. This does, however, result in the ordering of elements becoming unstable so may not be suitable where element order is still important.- Type Parameters:
T- the type of the elements in the list.U- the type of the first object used for predicate evaluation.V- the type of the second object used for predicate evaluation.W- the type of the third object used for predicate evaluation.- Parameters:
list- the list from which elements will be removed; must not be null.obj1- an optional object passed to the predicate for condition evaluation; may be null.obj2- an optional object passed to the predicate for condition evaluation; may be null.obj3- an optional object passed to the predicate for condition evaluation; may be null.predicate- the condition used to determine whether an element should be removed; must not be null.
-
emptyOrAllNull
-
binarySearch
public static <T,V> int binarySearch(@Nonnull List<? extends T> l, @Nonnull Function<T, V> func, V key, @Nonnull Comparator<? super V> c)
-