src/share/classes/java/util/ArrayList.java

Print this page
rev 7994 : 8024291: Rename Collection.removeIf(Predicate) back to removeAll(Predicate)
Reviewed-by: duke


1358                         @SuppressWarnings("unchecked") E e = (E) a[i];
1359                         action.accept(e);
1360                     }
1361                     if (lst.modCount == mc)
1362                         return;
1363                 }
1364             }
1365             throw new ConcurrentModificationException();
1366         }
1367 
1368         public long estimateSize() {
1369             return (long) (getFence() - index);
1370         }
1371 
1372         public int characteristics() {
1373             return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
1374         }
1375     }
1376 
1377     @Override
1378     public boolean removeIf(Predicate<? super E> filter) {
1379         Objects.requireNonNull(filter);
1380         // figure out which elements are to be removed
1381         // any exception thrown from the filter predicate at this stage
1382         // will leave the collection unmodified
1383         int removeCount = 0;
1384         final BitSet removeSet = new BitSet(size);
1385         final int expectedModCount = modCount;
1386         final int size = this.size;
1387         for (int i=0; modCount == expectedModCount && i < size; i++) {
1388             @SuppressWarnings("unchecked")
1389             final E element = (E) elementData[i];
1390             if (filter.test(element)) {
1391                 removeSet.set(i);
1392                 removeCount++;
1393             }
1394         }
1395         if (modCount != expectedModCount) {
1396             throw new ConcurrentModificationException();
1397         }
1398 




1358                         @SuppressWarnings("unchecked") E e = (E) a[i];
1359                         action.accept(e);
1360                     }
1361                     if (lst.modCount == mc)
1362                         return;
1363                 }
1364             }
1365             throw new ConcurrentModificationException();
1366         }
1367 
1368         public long estimateSize() {
1369             return (long) (getFence() - index);
1370         }
1371 
1372         public int characteristics() {
1373             return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
1374         }
1375     }
1376 
1377     @Override
1378     public boolean removeAll(Predicate<? super E> filter) {
1379         Objects.requireNonNull(filter);
1380         // figure out which elements are to be removed
1381         // any exception thrown from the filter predicate at this stage
1382         // will leave the collection unmodified
1383         int removeCount = 0;
1384         final BitSet removeSet = new BitSet(size);
1385         final int expectedModCount = modCount;
1386         final int size = this.size;
1387         for (int i=0; modCount == expectedModCount && i < size; i++) {
1388             @SuppressWarnings("unchecked")
1389             final E element = (E) elementData[i];
1390             if (filter.test(element)) {
1391                 removeSet.set(i);
1392                 removeCount++;
1393             }
1394         }
1395         if (modCount != expectedModCount) {
1396             throw new ConcurrentModificationException();
1397         }
1398