Here you can find the source of containsAny(Set theList, Set toSearch)
Parameter | Description |
---|---|
theList | Set the elements to look for |
toSearch | Set the search set |
public static boolean containsAny(Set theList, Set toSearch)
//package com.java2s; // The MIT License import java.util.Set; import java.util.Iterator; public class Main { /**/*from ww w .j a va 2 s .c om*/ * Checks to see if any elements of one set are present in another. * First parameter is the list of elements to search for, the second * parameter is the list to search in. Basically tests to see if the two sets intersect * @param theList Set the elements to look for * @param toSearch Set the search set * @return boolean true if any element in the first set is present in the second */ public static boolean containsAny(Set theList, Set toSearch) { if (toSearch.isEmpty()) return false; else { Iterator iter = theList.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (toSearch.contains(obj)) return true; } return false; } } }