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)
| 768 | |
| 769 | |
| 770 | public static <T> int indexOf(Iterator<T> iterator, Predicate<? super T> predicate) { |
| 771 | checkNotNull(predicate, "predicate"); |
| 772 | for (int i = 0; iterator.hasNext(); i++) { |
| 773 | T current = iterator.next(); |
| 774 | if (predicate.apply(current)) { |
| 775 | return i; |
| 776 | } |
| 777 | } |
| 778 | return -1; |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * Returns a view containing the result of applying {@code function} to each |