public static < T , IV > int detectIndexWith ( T [ ] objectArray , Predicate2 < ? super T , IV > predicate , IV injectedValue ) { if ( objectArray == null ) { throw new IllegalArgumentException ( "Cannot perform a detectIndexWith on null" ) ; } for ( int i = 0 ; i < objectArray . length ; i ++ ) { if ( predicate . accept ( objectArray [ i ] , injectedValue ) ) { return i ; } } return - 1 ; }
Searches for the first index where the predicate evaluates to true . Returns - 1 for no matches .