public static <T> int findIndexOf(Iterable<T> iterable, IFunction<? super T, Boolean> predicate) {
    int index = 0;
    for (T elem : iterable) {
      if (predicate.apply(elem)) return index;
      index++;
    }
    return -1;
  }
(Partial) replacement for Arrays.copyOfRange, which is only available in JDK6.
spock-core/src/main/java/org/spockframework/util/CollectionUtil.java