MCPcopy Create free account
hub / github.com/davidgiven/luje / retainAll

Method retainAll

lib/java/util/AbstractCollection.java:315–325  ·  view source on GitHub ↗

Removes all objects from this Collection that are not also found in the Collection passed (optional). After this method returns this Collection will only contain elements that also can be found in the Collection passed to this method. This implementation iterates

(Collection<?> collection)

Source from the content-addressed store, hash-verified

313 * if {@code collection} is {@code null}.
314 */
315 public boolean retainAll(Collection<?> collection) {
316 boolean result = false;
317 Iterator<?> it = iterator();
318 while (it.hasNext()) {
319 if (!collection.contains(it.next())) {
320 it.remove();
321 result = true;
322 }
323 }
324 return result;
325 }
326
327 /**
328 * Returns a count of how many objects this {@code Collection} contains.

Callers

nothing calls this directly

Calls 5

iteratorMethod · 0.95
hasNextMethod · 0.65
containsMethod · 0.65
nextMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected