public class Sets
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <E> void |
assertEquals(java.util.Set<E> first,
java.util.Set<E> second,
java.lang.String firstName,
java.lang.String secondName,
boolean outputShared,
java.util.function.Supplier<java.lang.String> errorMessage)
Tests whether two sets are equal.
|
static <E,F> java.util.Set<Pair<E,F>> |
cross(java.util.Set<E> s1,
java.util.Set<F> s2)
Returns the set cross product of s1 and s2, as
Pair s |
static <E> java.util.Set<E> |
diff(java.util.Set<E> s1,
java.util.Set<E> s2)
Returns the difference of sets s1 and s2.
|
static <E> java.util.Set<E> |
intersection(java.util.Set<E> s1,
java.util.Set<E> s2)
Returns the intersection of sets s1 and s2.
|
static <E> boolean |
intersects(java.util.Set<E> s1,
java.util.Set<E> s2)
Returns true if there is at least element that is in both s1 and s2.
|
static void |
main(java.lang.String[] args) |
static <E,F> java.util.Set<F> |
map(java.util.Set<E> oldSet,
java.util.function.Function<E,F> lambda) |
static <E> java.util.Set<java.util.Set<E>> |
powerSet(java.util.Set<E> s)
Returns the powerset (the set of all subsets) of set s.
|
static <E> java.util.Set<E> |
symmetricDiff(java.util.Set<E> s1,
java.util.Set<E> s2)
Returns the symmetric difference of sets s1 and s2 (i.e.
|
static <E> java.util.Set<E> |
union(java.util.Set<E> s1,
java.util.Set<E> s2)
Returns the union of sets s1 and s2.
|
public static <E,F> java.util.Set<F> map(java.util.Set<E> oldSet, java.util.function.Function<E,F> lambda)
public static <E,F> java.util.Set<Pair<E,F>> cross(java.util.Set<E> s1, java.util.Set<F> s2)
Pair
spublic static <E> java.util.Set<E> diff(java.util.Set<E> s1, java.util.Set<E> s2)
public static <E> java.util.Set<E> symmetricDiff(java.util.Set<E> s1, java.util.Set<E> s2)
public static <E> java.util.Set<E> union(java.util.Set<E> s1, java.util.Set<E> s2)
public static <E> java.util.Set<E> intersection(java.util.Set<E> s1, java.util.Set<E> s2)
public static <E> boolean intersects(java.util.Set<E> s1, java.util.Set<E> s2)
public static <E> java.util.Set<java.util.Set<E>> powerSet(java.util.Set<E> s)
public static <E> void assertEquals(java.util.Set<E> first, java.util.Set<E> second, java.lang.String firstName, java.lang.String secondName, boolean outputShared, java.util.function.Supplier<java.lang.String> errorMessage)
first
- a set to comparesecond
- a set to compare againstfirstName
- the name of the first set, used if an error occurssecondName
- the name of the second set, used if an error occursoutputShared
- output the common values for the two setserrorMessage
- a Supplier of an error message, in case it is expensive to generatepublic static void main(java.lang.String[] args)