Class ArrayHelper

java.lang.Object
net.sf.colossus.util.ArrayHelper

public class ArrayHelper extends Object
A collection of static methods to help with using arrays of the Java language. This is an addition to Arrays.
  • Constructor Details

    • ArrayHelper

      public ArrayHelper()
  • Method Details

    • findFirstMatch

      public static <T> T findFirstMatch(T[] input, Predicate<T> predicate)
      Find the first element in the array that matches the predicate.
      Type Parameters:
      T - The type of element to use.
      Parameters:
      input - The array of candidates to match. Not null.
      predicate - The match condition. Not null.
      Returns:
      The first match or null if there is none.
    • findFirstMatch

      public static <T> T findFirstMatch(T[][] input, Predicate<T> predicate)
      Find the first element in the array that matches the predicate. This is a two-dimensional version of #findFirstMatch(T[], Predicate), iteration is right-to-left as usual in Java.
      Type Parameters:
      T - The type of element to use.
      Parameters:
      input - The array of candidates to match. Not null.
      predicate - The match condition. Not null.
      Returns:
      The first match or null if there is none.