I don't know any API but have used following methods do such things on Set.
public static Set union(Set setA, Set setB) {
Set tmp = new TreeSet(setA);
tmp.addAll(setB);
return tmp;
}
public static Set intersection(Set setA, Set setB) {
Set tmp = new TreeSet();
for (T x : setA)
if (setB.contains(x))
tmp.add(x);
return tmp;
}
public static Set difference(Set setA, Set setB) {
Set tmp = new TreeSet(setA);
tmp.removeAll(setB);
return tmp;
}
public static Set symDifference(Set setA, Set setB) {
Set tmpA;
Set tmpB;
tmpA = union(setA, setB);
tmpB = intersection(setA, setB);
return difference(tmpA, tmpB);
}
public static boolean isSubset(Set setA, Set setB) {
return setB.containsAll(setA);
}
public static boolean isSuperset(Set setA, Set setB) {
return setA.containsAll(setB);
}
Reference: Set operations: union, intersection, difference, symmetric difference, is subset, is superset