public abstract class Sets extends Object
Set
s.
The various operations like union(Set, Set)
and so on assume an immutable use of the sets used as
parameters, since they are optimized to return one of
the input sets instead of new sets when possible.
I wished I had Guava available!Modifier and Type | Method and Description |
---|---|
static <T> Set<T> |
add(T elt,
Set<T> s) |
static <T> Set<T> |
create() |
static <T> Set<T> |
diff(Set<T> s1,
Set<T> s2) |
static <T> Set<T> |
empty() |
static <T> Set<T> |
inter(Set<T> s1,
Set<T> s2) |
static <T> Set<T> |
singleton(T elt) |
static <T> Set<T> |
symdiff(Set<T> s1,
Set<T> s2) |
static <T> Set<T> |
union(Set<T> s1,
Set<T> s2) |
public static <T> Set<T> empty()
public static <T> Set<T> singleton(T elt)
elt
- elt
public static <T> Set<T> add(T elt, Set<T> s)
elt
- s
- x
has been added
to the elements of s
public static <T> Set<T> union(Set<T> s1, Set<T> s2)
s1
- s2
- s1
and s2
public static <T> Set<T> inter(Set<T> s1, Set<T> s2)
s1
- s2
- s1
and s2
public static <T> Set<T> diff(Set<T> s1, Set<T> s2)
s1
- s2
- s1
and not in s2
public static <T> Set<T> symdiff(Set<T> s1, Set<T> s2)
s1
- s2
- s1
and s2
public static <T> Set<T> create()