Package net.sf.colossus.util
Class ArrayHelper
- java.lang.Object
-
- net.sf.colossus.util.ArrayHelper
-
public class ArrayHelper extends java.lang.Object
A collection of static methods to help with using arrays of the Java language. This is an addition toArrays
.
-
-
Constructor Summary
Constructors Constructor Description ArrayHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
findFirstMatch(T[][] input, Predicate<T> predicate)
Find the first element in the array that matches the predicate.static <T> T
findFirstMatch(T[] input, Predicate<T> predicate)
Find the first element in the array that matches the predicate.
-
-
-
Method Detail
-
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.
-
-