# Print output for @column tags ?>
public
class
Sets
extends Object
java.lang.Object | |
↳ | com.google.android.collect.Sets |
Provides static methods for creating mutable Set
instances easily and
other static methods for working with Sets.
Public constructors | |
---|---|
Sets()
|
Public methods | |
---|---|
static
<E>
ArraySet<E>
|
newArraySet()
Creates a |
static
<E>
ArraySet<E>
|
newArraySet(E... elements)
Creates a |
static
<E>
HashSet<E>
|
newHashSet(E... elements)
Creates a |
static
<K>
HashSet<K>
|
newHashSet()
Creates an empty |
static
<E>
SortedSet<E>
|
newSortedSet(E... elements)
Creates a |
static
<E>
SortedSet<E>
|
newSortedSet()
Creates an empty |
Inherited methods | |
---|---|
public Sets ()
public static ArraySet<E> newArraySet ()
Creates a ArraySet
instance.
Returns | |
---|---|
ArraySet<E> |
public static ArraySet<E> newArraySet (E... elements)
Creates a ArraySet
instance containing the given elements.
Parameters | |
---|---|
elements |
E |
Returns | |
---|---|
ArraySet<E> |
public static HashSet<E> newHashSet (E... elements)
Creates a HashSet
instance containing the given elements.
Note: due to a bug in javac 1.5.0_06, we cannot support the following:
Set<Base> set = Sets.newHashSet(sub1, sub2);
where sub1
and sub2
are references to subtypes of Base
, not of Base
itself. To get around this, you must use:
Set<Base> set = Sets.<Base>newHashSet(sub1, sub2);
Parameters | |
---|---|
elements |
E : the elements that the set should contain |
Returns | |
---|---|
HashSet<E> |
a newly-created HashSet containing those elements (minus
duplicates) |
public static HashSet<K> newHashSet ()
Creates an empty HashSet
instance.
Note: if E
is an Enum
type, use EnumSet#noneOf
instead.
Note: if you only need an immutable empty Set,
use Collections#emptySet
instead.
Returns | |
---|---|
HashSet<K> |
a newly-created, initially-empty HashSet |