--- old/src/share/classes/java/util/Collection.java 2012-12-10 21:19:06.971766079 -0800
+++ new/src/share/classes/java/util/Collection.java 2012-12-10 21:19:06.799766074 -0800
@@ -25,6 +25,8 @@
package java.util;
+import java.util.function.Predicate;
+
/**
* The root interface in the collection hierarchy. A collection
* represents a group of objects, known as its elements. Some
@@ -453,4 +455,28 @@
* @see Object#equals(Object)
*/
int hashCode();
+
+ /**
+ * Removes all of the elements of this collection which match the provided
+ * predicate.
+ *
+ * @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 predicate is null
+ * @since 1.8
+ */
+ public default boolean removeAll(Predicate super E> filter) {
+ Objects.requireNonNull(filter);
+ boolean removed = false;
+ Iterator each = iterator();
+ while (each.hasNext()) {
+ if (filter.test(each.next())) {
+ each.remove();
+ removed = true;
+ }
+ }
+
+ return removed;
+ }
}