4524 |
|
return true; |
4525 |
|
} |
4526 |
|
|
4527 |
< |
public final boolean removeAll(Collection<?> c) { |
4527 |
> |
public boolean removeAll(Collection<?> c) { |
4528 |
|
if (c == null) throw new NullPointerException(); |
4529 |
|
boolean modified = false; |
4530 |
< |
for (Iterator<E> it = iterator(); it.hasNext();) { |
4531 |
< |
if (c.contains(it.next())) { |
4532 |
< |
it.remove(); |
4533 |
< |
modified = true; |
4530 |
> |
// Use (c instanceof Set) as a hint that lookup in c is as |
4531 |
> |
// efficient as this view |
4532 |
> |
if (c instanceof Set<?> && c.size() > map.table.length) { |
4533 |
> |
for (Iterator<?> it = iterator(); it.hasNext(); ) { |
4534 |
> |
if (c.contains(it.next())) { |
4535 |
> |
it.remove(); |
4536 |
> |
modified = true; |
4537 |
> |
} |
4538 |
|
} |
4539 |
+ |
} else { |
4540 |
+ |
for (Object e : c) |
4541 |
+ |
modified |= remove(e); |
4542 |
|
} |
4543 |
|
return modified; |
4544 |
|
} |
4725 |
|
throw new UnsupportedOperationException(); |
4726 |
|
} |
4727 |
|
|
4728 |
+ |
@Override public boolean removeAll(Collection<?> c) { |
4729 |
+ |
if (c == null) throw new NullPointerException(); |
4730 |
+ |
boolean modified = false; |
4731 |
+ |
for (Iterator<V> it = iterator(); it.hasNext();) { |
4732 |
+ |
if (c.contains(it.next())) { |
4733 |
+ |
it.remove(); |
4734 |
+ |
modified = true; |
4735 |
+ |
} |
4736 |
+ |
} |
4737 |
+ |
return modified; |
4738 |
+ |
} |
4739 |
+ |
|
4740 |
|
public boolean removeIf(Predicate<? super V> filter) { |
4741 |
|
return map.removeValueIf(filter); |
4742 |
|
} |