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.270 by jsr166, Tue Mar 24 22:30:53 2015 UTC vs.
Revision 1.271 by dl, Tue Apr 28 23:06:53 2015 UTC

# Line 31 | Line 31 | import java.util.function.DoubleBinaryOp
31   import java.util.function.Function;
32   import java.util.function.IntBinaryOperator;
33   import java.util.function.LongBinaryOperator;
34 + import java.util.function.Predicate;
35   import java.util.function.ToDoubleBiFunction;
36   import java.util.function.ToDoubleFunction;
37   import java.util.function.ToIntBiFunction;
# Line 1593 | Line 1594 | public class ConcurrentHashMap<K,V> exte
1594      }
1595  
1596      /**
1597 +     * Helper method for EntrySet.removeIf
1598 +     */
1599 +    boolean removeEntryIf(Predicate<? super Entry<K, V>> function) {
1600 +        if (function == null) throw new NullPointerException();
1601 +        Node<K,V>[] t;
1602 +        boolean removed = false;
1603 +        if ((t = table) != null) {
1604 +            Traverser<K,V> it = new Traverser<K,V>(t, t.length, 0, t.length);
1605 +            for (Node<K,V> p; (p = it.advance()) != null; ) {
1606 +                K k = p.key;
1607 +                V v = p.val;
1608 +                Map.Entry<K,V> e = new AbstractMap.SimpleImmutableEntry<>(k, v);
1609 +                if (function.test(e) && replaceNode(k, null, v) != null)
1610 +                    removed = true;
1611 +            }
1612 +        }
1613 +        return removed;
1614 +    }
1615 +
1616 +    /**
1617       * If the specified key is not already associated with a value,
1618       * attempts to compute its value using the given mapping function
1619       * and enters it into this map unless {@code null}.  The entire
# Line 4739 | Line 4760 | public class ConcurrentHashMap<K,V> exte
4760              return added;
4761          }
4762  
4763 +        public boolean removeIf(Predicate<? super Entry<K, V>> filter) {
4764 +            return map.removeEntryIf(filter);
4765 +        }
4766 +
4767          public final int hashCode() {
4768              int h = 0;
4769              Node<K,V>[] t;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines