public static boolean existPairwiseIntersections ( Collection < Set < String > > sets ) { // Determine all possible pairs of sets List < List < Set < String >>> setPairs = ListUtils . getKElementaryLists ( new ArrayList < Set < String > > ( sets ) , 2 ) ; for ( Iterator < List < Set < String > > > iter = setPairs . iterator ( ) ; iter . hasNext ( ) ; ) { Set < String > intersection = SetUtils . intersection ( iter . next ( ) ) ; if ( ! intersection . isEmpty ( ) ) { return true ; } } return false ; }
Checks if any two of the given sets intersect .