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

Method tryFind

output/java_guava/1.4.19/Iterators.java:747–750  ·  view source on GitHub ↗

Returns an Optional containing the first element in iterator that satisfies the given predicate, if such an element exists. If no such element is found, an empty Optional will be returned from this method and the iterator will be left exhausted: its hasNext() method w

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

Source from the content-addressed store, hash-verified

745
746
747 public static <T> Optional<T> tryFind(Iterator<T> iterator, Predicate<? super T> predicate) {
748 UnmodifiableIterator<T> filteredIterator = filter(iterator, predicate);
749 return filteredIterator.hasNext() ? Optional.of(filteredIterator.next()) : Optional.<T>absent();
750 }
751
752 /**
753 * Returns the index in {@code iterator} of the first element that satisfies

Callers 1

tryFindMethod · 0.95

Calls 5

filterMethod · 0.95
ofMethod · 0.95
absentMethod · 0.95
nextMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected