/**
* Find the difference set of LS to LS2, that is, LS, but not in the LS2
*
* @param ls
* @param LS2
* @return
*/
public static list diff (list ls, list ls2) {
List List = new ArrayList (arrays.aslist (New Object[ls.size ()));
Collections.copy (list, LS);
List.removeall (LS2);
return list;
}
/**
* Find the intersection of 2 sets
*
* @param ls
* @param ls2
* @return
*/
public static list intersect (list ls, list ls2) {
list = new ArrayList (arrays.aslist (New Object[ls.size ()));
collections.copy (list, LS);
List.retainall (LS2);
return list;
}
/**
* Find a set of 2 sets
*
* @param ls
* @param LS2
* @return
*/
public static list Union (list ls, list ls2) {
List List = new ArrayList (arrays.aslist (New Object[ls.size ()));
Collections.copy (list, LS);//Copy the value of LS to the list
List.removeall (LS2);
List.addall (LS2);
return list;
}
Collection operations for Java (intersection, set, difference) collation