Package org.networkcalculus.dnc.utils
Class SetUtils
- java.lang.Object
-
- org.networkcalculus.dnc.utils.SetUtils
-
public final class SetUtils extends java.lang.Object
A tiny collection of convenience methods useful in dealing with sets but not provided directly by Java's set classes.
-
-
Constructor Summary
Constructors Constructor Description SetUtils()
-
Method Summary
Modifier and Type Method Description static <T> java.util.Set<T>
getDifference(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the set difference between the sets1
and the sets2
.static <T> java.util.Set<T>
getIntersection(java.util.List<java.util.Set<T>> sets)
Returns the intersection of all sets contained in the listsets
.static <T> java.util.Set<T>
getIntersection(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the intersection of sets1
and sets2
.static <T> java.util.Set<T>
getUnion(java.util.List<java.util.Set<T>> sets)
Returns the union of all sets contained in the listsets
.static <T> java.util.Set<T>
getUnion(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the union of sets1
and sets2
.
-
-
-
Method Detail
-
getDifference
public static <T> java.util.Set<T> getDifference(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the set difference between the sets1
and the sets2
.- Type Parameters:
T
- Type of the sets' entries.- Parameters:
s1
- A set.s2
- Another set.- Returns:
- The difference set.
-
getIntersection
public static <T> java.util.Set<T> getIntersection(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the intersection of sets1
and sets2
. Returns an empty set if the intersection is empty, i.e., does not return null.- Type Parameters:
T
- Type of the sets' entries.- Parameters:
s1
- A set.s2
- Another set.- Returns:
- The intersection set.
-
getIntersection
public static <T> java.util.Set<T> getIntersection(java.util.List<java.util.Set<T>> sets)
Returns the intersection of all sets contained in the listsets
.- Type Parameters:
T
- Type of the sets' entries.- Parameters:
sets
- A list of sets- Returns:
- The intersection of all sets
-
getUnion
public static <T> java.util.Set<T> getUnion(java.util.Set<T> s1, java.util.Set<T> s2)
Returns the union of sets1
and sets2
.- Type Parameters:
T
- Type of the sets' entries.- Parameters:
s1
- A set.s2
- Another set.- Returns:
- The union set.
-
getUnion
public static <T> java.util.Set<T> getUnion(java.util.List<java.util.Set<T>> sets)
Returns the union of all sets contained in the listsets
.- Type Parameters:
T
- Type of the sets' entries.- Parameters:
sets
- A list of sets.- Returns:
- The union of all sets.
-
-