MCPcopy
hub / github.com/google/guava / retainAll

Method retainAll

guava/src/com/google/common/collect/Maps.java:4215–4234  ·  view source on GitHub ↗
(Collection<?> c)

Source from the content-addressed store, hash-verified

4213 }
4214
4215 @Override
4216 public boolean retainAll(Collection<?> c) {
4217 try {
4218 return super.retainAll(checkNotNull(c));
4219 } catch (UnsupportedOperationException e) {
4220 // if the iterators don't support remove
4221 Set<@Nullable Object> keys = Sets.newHashSetWithExpectedSize(c.size());
4222 for (Object o : c) {
4223 /*
4224 * `o instanceof Entry` is guaranteed by `contains`, but we check it here to satisfy our
4225 * nullness checker.
4226 */
4227 if (contains(o) && o instanceof Entry) {
4228 Entry<?, ?> entry = (Entry<?, ?>) o;
4229 keys.add(entry.getKey());
4230 }
4231 }
4232 return map().keySet().retainAll(keys);
4233 }
4234 }
4235 }
4236
4237 @GwtIncompatible // NavigableMap

Callers

nothing calls this directly

Calls 9

containsMethod · 0.95
mapMethod · 0.95
retainAllMethod · 0.65
sizeMethod · 0.65
addMethod · 0.65
getKeyMethod · 0.65
keySetMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected