Java Collection Intersect intersects(Collection c1, Collection c2)

Here you can find the source of intersects(Collection c1, Collection c2)

Description

Checks if two collections have any elemnts in common

License

Open Source License

Parameter

Parameter Description
coll A Collection of sets

Declaration

public static boolean intersects(Collection c1, Collection c2) 

Method Source Code


//package com.java2s;
//The MIT License

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**//from w w  w .ja va2s. c o  m
     * Checks if two collections have any elemnts in common 
     * 
     * @param coll A Collection of sets
     */
    public static boolean intersects(Collection c1, Collection c2) {
        for (Iterator i = c1.iterator(); i.hasNext();) {
            if (c2.contains(i.next()))
                return true;
        }

        return false;
    }
}

Related

  1. intersection(final Collection a, final Collection b)
  2. intersection(final Collection c1, final Collection c2)
  3. intersection(final Collection a, final Collection b)
  4. intersection(final Collection c1, final Collection c2)
  5. intersectionSize(Collection c1, Collection c2)
  6. intersects(Collection c0, Collection c1)
  7. intersectsWith(Collection S1, Collection S2)
  8. makeIntersection(Collection a, Collection b)
  9. sizeOfIntersection(Collection a, Collection b)