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

Method removeFirstMatching

output/java_guava/1.4.16/Iterables.java:253–265  ·  view source on GitHub ↗

Removes and returns the first matching element, or returns null if there is none.

(Iterable<T> removeFrom, Predicate<? super T> predicate)

Source from the content-addressed store, hash-verified

251 */
252
253 @Nullable
254 static <T> T removeFirstMatching(Iterable<T> removeFrom, Predicate<? super T> predicate) {
255 checkNotNull(predicate);
256 Iterator<T> iterator = removeFrom.iterator();
257 while (iterator.hasNext()) {
258 T next = iterator.next();
259 if (predicate.apply(next)) {
260 iterator.remove();
261 return next;
262 }
263 }
264 return null;
265 }
266
267 /**
268 * Determines whether two iterables contain equal elements in the same order.

Callers 5

removeMethod · 0.95
pollFirstEntryMethod · 0.95
pollLastEntryMethod · 0.95
pollFirstMethod · 0.95
pollLastMethod · 0.95

Calls 6

iteratorMethod · 0.65
nextMethod · 0.65
applyMethod · 0.65
removeMethod · 0.65
checkNotNullMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected