public class SetUtils extends Object
| Constructor and Description |
|---|
SetUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Set<T> |
add(T o,
Set<T> set)
Adds the given object to the set but saves memory space
by allocating only the required amount for small sets.
|
static <T> Set<T> |
binary(T o1,
T o2) |
static <T> Set<T> |
create(Collection<T> coll)
Creates a set containing all the elements in the collection
|
static <T> Set<T> |
create(T... elems)
Creates a list containing all the elements in the array
|
static <T> Set<T> |
difference(Collection<T> c1,
Collection<? extends Object> c2)
Returns the difference of two sets.
|
static <T> Set<T> |
emptySet() |
static <T> boolean |
equals(Set<T> s1,
Set<T> s2)
Checks if one set is equal of another one
|
static <T> Set<T> |
intersection(Collection<? extends Collection<? extends T>> coll)
Returns the intersection of all the collections given in a collection.
|
static <T> Set<T> |
intersection(Collection<? extends T> c1,
Collection<? extends T> c2)
Returns the intersection of two collections
|
static boolean |
intersects(Collection<?> c1,
Collection<?> c2)
Checks if two collections have any elements in common
|
static <T> Set<T> |
remove(Object o,
Set<T> set) |
static <T> Set<T> |
singleton(T o) |
static boolean |
subset(Set<?> sub,
Set<?> sup)
Checks if one set is subset of another one
|
static <T> Set<T> |
union(Collection<? extends Collection<? extends T>> coll)
Returns the union of all the sets given in a collection.
|
static <T> Set<T> |
union(Collection<? extends T> c1,
Collection<? extends T> c2)
Returns the union of two collections
|
public static final Set<?> EMPTY_SET
public static <T> Set<T> add(T o, Set<T> set)
o - set - public static final <T> Set<T> emptySet()
public static final <T> Set<T> singleton(T o)
public static final <T> Set<T> binary(T o1, T o2)
public static <T> Set<T> union(Collection<? extends Collection<? extends T>> coll)
coll - A Collection of setspublic static <T> Set<T> union(Collection<? extends T> c1, Collection<? extends T> c2)
coll - A Collection of setspublic static <T> Set<T> intersection(Collection<? extends Collection<? extends T>> coll)
coll - A Collection of setspublic static <T> Set<T> intersection(Collection<? extends T> c1, Collection<? extends T> c2)
coll - A Collection of setspublic static boolean intersects(Collection<?> c1, Collection<?> c2)
public static boolean subset(Set<?> sub, Set<?> sup)
sub - sup - public static <T> boolean equals(Set<T> s1, Set<T> s2)
sub - sup - public static <T> Set<T> difference(Collection<T> c1, Collection<? extends Object> c2)
coll - A Collection of setspublic static <T> Set<T> create(T... elems)
elements - public static <T> Set<T> create(Collection<T> coll)
elements - Copyright © 2019. All rights reserved.