vavr-io / vavr

vʌvr (formerly called Javaslang) is a non-commercial, non-profit object-functional library that runs with Java 8+. It aims to reduce the lines of code and increase code quality.
https://vavr.io
Other
5.73k stars 637 forks source link

Add `removeAll` to `Traversable` #1305

Open l0rinc opened 8 years ago

l0rinc commented 8 years ago

removeAll and retainAll seem to have the same usages, I think they should come in pairs: where there is one, the other should be also.

Traversable should:

    /**
     * Removes all occurrences of the given elements.
     *
     * @param elements Elements to be removed from this Seq.
     * @return a Traversable containing all elements of this but none of the given elements.
     * @throws NullPointerException if {@code elements} is null
     */
    Traversable<T> removeAll(Iterable<? extends T> elements);

and Iterator impement it via a default method:

    @Override
    default Iterator<T> removeAll(Iterable<? extends T> elements) {
        return Collections.removeAll(this, elements);
    }

Some incompatibilities should be resolved in Map also.

danieldietrich commented 8 years ago

I think the reason was the API incompatibility between Set/Seq and Map. Scala also does not have remove* in Traversable. But Scala also has not retainAll as part of Traversable.

Another option is to remove retainAll from Traversable...