src/share/classes/java/util/Collection.java
Print this page
rev 7994 : 8024291: Rename Collection.removeIf(Predicate) back to removeAll(Predicate)
Reviewed-by: duke
@@ -377,12 +377,12 @@
*/
boolean removeAll(Collection<?> c);
/**
* Removes all of the elements of this collection that satisfy the given
- * predicate. Errors or runtime exceptions thrown by the predicate are
- * relayed to the caller.
+ * predicate. Errors or runtime exceptions thrown during iteration or by
+ * the predicate are relayed to the caller.
*
* @implSpec
* The default implementation traverses all elements of the collection using
* its {@link #iterator}. Each matching element is removed using
* {@link Iterator#remove()}. If the collection's iterator does not
@@ -391,16 +391,15 @@
*
* @param filter a predicate which returns {@code true} for elements to be
* removed
* @return {@code true} if any elements were removed
* @throws NullPointerException if the specified filter is null
- * @throws UnsupportedOperationException if the {@code remove}
- * method is not supported by this collection's
- * {@link #iterator}
+ * @throws UnsupportedOperationException if a matching element cannot be
+ * removed from this collection
* @since 1.8
*/
- default boolean removeIf(Predicate<? super E> filter) {
+ default boolean removeAll(Predicate<? super E> filter) {
Objects.requireNonNull(filter);
boolean removed = false;
final Iterator<E> each = iterator();
while (each.hasNext()) {
if (filter.test(each.next())) {