我似乎无法在 Eclipse Collections 中找到类型的containsAny()
方法。SetIterable
有吗?
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.
写一个很容易:
/**
* 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();
}
但我只是想知道一个是否已经存在。