ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java (file contents):
Revision 1.294 by dl, Wed Jun 8 19:44:32 2016 UTC vs.
Revision 1.295 by jsr166, Sun Jul 17 04:23:31 2016 UTC

# Line 4524 | Line 4524 | public class ConcurrentHashMap<K,V> exte
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          }
# Line 4718 | Line 4725 | public class ConcurrentHashMap<K,V> exte
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          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines