The list of methods to do Collection Intersect are organized into topic(s).
Collection>
getIntersection( final Collection extends Collection extends Object>> collections) get Intersection
final List<Collection<?>> collectionsList = new ArrayList<Collection<?>>(collections);
final Collection<Object> intersection = new HashSet<>();
if (collectionsList.size() != 0) {
intersection.addAll(collectionsList.get(0));
for (int i = 1; i < collections.size() && intersection.size() > 0; i++) {
intersection.retainAll(new HashSet<>(collectionsList.get(i)));
return intersection;
boolean
hasIntersection(final Collection a, final Collection b) Returns
true iff the given Collection s.
if (a.size() < 50 && b.size() < 50) {
Iterator it = a.iterator();
while (it.hasNext())
if (b.contains(it.next()))
return true;
} else if (a.size() < b.size()) {
HashSet bSet = new HashSet(b);
Iterator it = a.iterator();
...
List
intersect(Collection c1, Collection c2) intersect
List c1_ = new ArrayList();
List c1__ = new ArrayList();
if (isNotEmpty(c1)) {
c1_.addAll(c1);
c1__.addAll(c1);
c1__.removeAll(c2);
c1_.removeAll(c1__);
return c1_;