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

Comparing jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java (file contents):
Revision 1.145 by jsr166, Wed Apr 29 18:01:41 2015 UTC vs.
Revision 1.146 by dl, Sun May 3 12:09:30 2015 UTC

# Line 2458 | Line 2458 | public class ConcurrentSkipListMap<K,V>
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  
# Line 2524 | Line 2538 | public class ConcurrentSkipListMap<K,V>
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines