/** * Removes elements of the given collection from this set. * This method avoids to invoke {@link #size()}. * * @param c the collection containing elements to remove. * @return {@code true} if at least one element has been removed. */ @Override public boolean removeAll(final Collection<?> c) { /* * Do not invoke super.removeAll(c) even if isSizeKnown() returns 'true' because we want to unconditionally * iterate over the elements of the given collection. The reason is that this Set may compute the values in * a dynamic way and it is sometime difficult to ensure that the values returned by this Set's iterator are * fully consistent with the values recognized by contains(Object) and remove(Object) methods. Furthermore * we want the operation to fail fast in the common case where the remove(Object) method is unsupported. */ boolean modified = false; for (final Iterator<?> it = c.iterator(); it.hasNext();) { modified |= remove(it.next()); } return modified; }
/** * Removes elements of the given collection from this set. * This method avoids to invoke {@link #size()}. * * @param c the collection containing elements to remove. * @return {@code true} if at least one element has been removed. */ @Override public boolean removeAll(final Collection<?> c) { /* * Do not invoke super.removeAll(c) even if isSizeKnown() returns 'true' because we want to unconditionally * iterate over the elements of the given collection. The reason is that this Set may compute the values in * a dynamic way and it is sometime difficult to ensure that the values returned by this Set's iterator are * fully consistent with the values recognized by contains(Object) and remove(Object) methods. Furthermore * we want the operation to fail fast in the common case where the remove(Object) method is unsupported. */ boolean modified = false; for (final Iterator<?> it = c.iterator(); it.hasNext();) { modified |= remove(it.next()); } return modified; }