Package de.isas.mztab2.cvmapping
Class SetOperations
- java.lang.Object
-
- de.isas.mztab2.cvmapping.SetOperations
-
public class SetOperations extends Object
Utility methods for sets with common names.- Author:
- nilshoffmann
-
-
Constructor Summary
Constructors Constructor Description SetOperations()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Set<T>
complement(Set<T> a, Set<T> b)
Returns the complement (a without elements also in b) ofa
andb
.static <T> Set<T>
intersection(Set<T> a, Set<T> b)
Returns the intersection (a \cap b, all common elements) ofa
andb
.static <T> Set<T>
newSet(Collection<? extends T> c)
Creates a new typedLinkedHashSet
(preserving order of insertion) from the given collection.static <T> Set<T>
symmetricDifference(Set<T> a, Set<T> b)
Returns the symmetric set difference (union(complement(a,b),complement(b,a))
) ona
andb
.static <T> Set<T>
union(Set<T> a, Set<T> b)
Returns the union (a+b) ofa
andb
.
-
-
-
Constructor Detail
-
SetOperations
public SetOperations()
-
-
Method Detail
-
newSet
public static <T> Set<T> newSet(Collection<? extends T> c)
Creates a new typedLinkedHashSet
(preserving order of insertion) from the given collection.- Type Parameters:
T
- the value type- Parameters:
c
- the collection- Returns:
- a new typed hash set
-
union
public static <T> Set<T> union(Set<T> a, Set<T> b)
Returns the union (a+b) ofa
andb
.- Type Parameters:
T
- the value type- Parameters:
a
- set ab
- set b- Returns:
- the union of a and b
-
intersection
public static <T> Set<T> intersection(Set<T> a, Set<T> b)
Returns the intersection (a \cap b, all common elements) ofa
andb
.- Type Parameters:
T
- the value type- Parameters:
a
- set ab
- set b- Returns:
- the intersection of a and b
-
complement
public static <T> Set<T> complement(Set<T> a, Set<T> b)
Returns the complement (a without elements also in b) ofa
andb
.- Type Parameters:
T
- the value type- Parameters:
a
- set ab
- set b- Returns:
- the complement of a and b
-
symmetricDifference
public static <T> Set<T> symmetricDifference(Set<T> a, Set<T> b)
Returns the symmetric set difference (union(complement(a,b),complement(b,a))
) ona
andb
.- Type Parameters:
T
- the value type- Parameters:
a
- set ab
- set b- Returns:
- the symmetric set difference
-
-