/** * A sensible definition of {@link #removeAll} in terms of {@link #iterator}, using the iterator's * {@code remove} method. If you override {@link #iterator}, you may wish to override {@link * #removeAll} to forward to this implementation. * * @since 7.0 */ protected boolean standardRemoveAll(Collection<?> collection) { return Iterators.removeAll(iterator(), collection); }
@Override public boolean removeAll(Collection<?> c) { synchronized (mutex) { return Iterators.removeAll(delegate().iterator(), c); } }
/** * Removes, from an iterable, every element that belongs to the provided collection. * * <p>This method calls {@link Collection#removeAll} if {@code iterable} is a collection, and * {@link Iterators#removeAll} otherwise. * * @param removeFrom the iterable to (potentially) remove elements from * @param elementsToRemove the elements to remove * @return {@code true} if any element was removed from {@code iterable} */ public static boolean removeAll(Iterable<?> removeFrom, Collection<?> elementsToRemove) { return (removeFrom instanceof Collection) ? ((Collection<?>) removeFrom).removeAll(checkNotNull(elementsToRemove)) : Iterators.removeAll(removeFrom.iterator(), elementsToRemove); }