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; |
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 |
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; |