2458 |
|
else |
2459 |
|
return (Spliterator<E>)((SubMap<?,E>)m).valueIterator(); |
2460 |
|
} |
2461 |
+ |
|
2462 |
|
public boolean removeIf(Predicate<? super E> filter) { |
2463 |
< |
return ((ConcurrentSkipListMap<?,E>)m).removeValueIf(filter); |
2463 |
> |
if (filter == null) throw new NullPointerException(); |
2464 |
> |
if (m instanceof ConcurrentSkipListMap) |
2465 |
> |
return ((ConcurrentSkipListMap<?,E>)m).removeValueIf(filter); |
2466 |
> |
// else use iterator |
2467 |
> |
@SuppressWarnings("unchecked") Iterator<Map.Entry<Object,E>> it = |
2468 |
> |
((SubMap<Object,E>)m).entryIterator(); |
2469 |
> |
boolean removed = false; |
2470 |
> |
while (it.hasNext()) { |
2471 |
> |
Map.Entry<Object,E> e = it.next(); |
2472 |
> |
E v = e.getValue(); |
2473 |
> |
if (filter.test(v) && m.remove(e.getKey(), v)) |
2474 |
> |
removed = true; |
2475 |
> |
} |
2476 |
> |
return removed; |
2477 |
|
} |
2478 |
|
} |
2479 |
|
|
2538 |
|
((SubMap<K1,V1>)m).entryIterator(); |
2539 |
|
} |
2540 |
|
public boolean removeIf(Predicate<? super Entry<K1, V1>> filter) { |
2541 |
< |
return ((ConcurrentSkipListMap<K1,V1>)m).removeEntryIf(filter); |
2541 |
> |
if (filter == null) throw new NullPointerException(); |
2542 |
> |
if (m instanceof ConcurrentSkipListMap) |
2543 |
> |
return ((ConcurrentSkipListMap<K1,V1>)m).removeEntryIf(filter); |
2544 |
> |
// else use iterator |
2545 |
> |
Iterator<Map.Entry<K1,V1>> it = ((SubMap<K1,V1>)m).entryIterator(); |
2546 |
> |
boolean removed = false; |
2547 |
> |
while (it.hasNext()) { |
2548 |
> |
Map.Entry<K1,V1> e = it.next(); |
2549 |
> |
if (filter.test(e) && m.remove(e.getKey(), e.getValue())) |
2550 |
> |
removed = true; |
2551 |
> |
} |
2552 |
> |
return removed; |
2553 |
|
} |
2554 |
|
} |
2555 |
|
|