MCPcopy Create free account
hub / github.com/antlr/codebuff / indexOf

Method indexOf

corpus/java/training/guava/collect/Iterators.java:728–737  ·  view source on GitHub ↗

Returns the index in iterator of the first element that satisfies the provided predicate, or -1 if the Iterator has no such elements. More formally, returns the lowest index i such that predicate.apply(Iterators.get(iterator, i)) returns true, or {

(Iterator<T> iterator, Predicate<? super T> predicate)

Source from the content-addressed store, hash-verified

726 * @since 2.0
727 */
728 public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate) {
729 checkNotNull(predicate, "predicate");
730 for (int i = 0; iterator.hasNext(); i++) {
731 T current = iterator.next();
732 if (predicate.apply(current)) {
733 return i;
734 }
735 }
736 return -1;
737 }
738
739 /**
740 * Returns a view containing the result of applying {@code function} to each

Callers 2

indexOfMethod · 0.95
anyMethod · 0.95

Calls 4

nextMethod · 0.65
applyMethod · 0.65
checkNotNullMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected