'Eclipse Collections - Is there a containsAny() method for Sets?

I can't seem to find a containsAny() method for SetIterable types in Eclipse Collections. Is there one?

MutableSet<String> set1 = Sets.mutable.of("a", "b", "c");
ImmutableSet<String> set2 = Sets.immutable.of("c", "d", "e");

set1.containsAny(set2); // I can't find this method.

It's easy enough to write one:

/**
 * True if [set1] contains any element in [set2].
 */
public static <T> boolean intersects(SetIterable<T> set1, SetIterable<? extends T> set2) {
    return set1.intersect(set2).notEmpty();
}

But I just wanted to know if one already existed.



Solution 1:[1]

I don't see a containsAny method, but you can do this:

set2.anySatisfy(set1::contains);

Solution 2:[2]

The methods containsAny and containsNone will be available on the RichIterable interface in the Eclipse Collections 11.1 release. There will also be methods named containsAnyIterable and containsNoneIterable which take Iterable as a parameter instead of Collection.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bliss
Solution 2 Donald Raab