SetUtils { public static <T> Set<T> union(Set<? extends T> s1, Set<? extends T> s2) { Set<T> s3 = new HashSet<>(s1) ; s3.addAll(s2) ; return s3 ; } private  SetUtils(); static final Set<X> concurrentHashSet(); static Set<T> intersection(Set<? extends T> setLeft, Set<? extends T> setRight); static boolean intersectionP(Set<? extends T> s1, Set<? extends T> s2); static Set<T> union(Set<? extends T> s1, Set<? extends T> s2); static Set<T> symmetricDifference(Set<? extends T> s1, Set<? extends T> s2); static Set<T> difference(Set<? extends T> s1, Set<? extends T> s2); static Set<T> toSet(Stream<T> stream);  }
@Test public void set_union_1() { Set<Integer> x1 = set(1,2,3) ; Set<Integer> x2 = set(1,2,3) ; Set<Integer> x3 = SetUtils.union(x1, x2) ; test(x3, 1,2,3) ; x3 = SetUtils.union(x2, x1) ; test(x3, 1,2,3) ; }
@Test public void set_union_2() { Set<Integer> x1 = set(1,2,3) ; Set<Integer> x2 = set(2,9) ; Set<Integer> x3 = SetUtils.union(x1, x2) ; test(x3, 1,2,3,9) ; x3 = SetUtils.union(x2, x1) ; test(x3, 1,2,3,9) ; }
@Test public void set_union_3() { Set<Integer> x1 = set(1,2,3) ; Set<Integer> x2 = set() ; Set<Integer> x3 = SetUtils.union(x1, x2) ; test(x3,1,2,3) ; x3 = SetUtils.union(x2, x1) ; test(x3,1,2,3) ; }