Class ListUtil

java.lang.Object
com.hypixel.hytale.common.util.ListUtil

public class ListUtil extends Object
Since:
07/11/2017
Version:
1.0
  • Constructor Details

    • ListUtil

      public ListUtil()
  • Method Details

    • partition

      @Nonnull public static <T> List<List<T>> partition(@Nonnull List<T> list, int sectionSize)
    • removeIf

      public static <T> void removeIf(@Nonnull List<T> list, @Nonnull Predicate<T> predicate)
    • removeIf

      public static <T,U> void removeIf(@Nonnull List<T> list, @Nonnull BiPredicate<T,U> predicate, U obj)
    • unstableRemoveIf

      public static <T,U,V> void unstableRemoveIf(@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,V,W> void unstableRemoveIf(@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

      public static <T> boolean emptyOrAllNull(@Nonnull List<T> list)
    • binarySearch

      public static <T,V> int binarySearch(@Nonnull List<? extends T> l, @Nonnull Function<T,V> func, V key, @Nonnull Comparator<? super V> c)