|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.inject.internal.util.Sets
public final class Sets
Static utility methods pertaining to Set
instances. Also see this
class's counterparts Lists
and Maps
.
Method Summary | ||
---|---|---|
static
|
newHashSet()
Creates an empty HashSet instance. |
|
static
|
newLinkedHashSet()
Creates an empty LinkedHashSet instance. |
|
static
|
newSetFromMap(Map<E,Boolean> map)
Returns a set backed by the specified map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <E> HashSet<E> newHashSet()
HashSet
instance.
Note: if E
is an Enum
type, use EnumSet.noneOf(java.lang.Class
instead.
Note: if you need an immutable empty Set, use Collections.emptySet()
instead.
HashSet
public static <E> LinkedHashSet<E> newLinkedHashSet()
LinkedHashSet
instance.
LinkedHashSet
public static <E> Set<E> newSetFromMap(Map<E,Boolean> map)
Set
implementation corresponding to any Map
implementation. There is no
need to use this method on a Map
implementation that already has a
corresponding Set
implementation (such as HashMap
or
TreeMap
).
Each method invocation on the set returned by this method results in exactly one method invocation on the backing map or its keySet view, with one exception. The addAll method is implemented as a sequence of put invocations on the backing map.
The specified map must be empty at the time this method is invoked, and should not be accessed directly after this method returns. These conditions are ensured if the map is created empty, passed directly to this method, and no reference to the map is retained, as illustrated in the following code fragment:
Set<Object> identityHashSet = Sets.newSetFromMap( new IdentityHashMap<Object, Boolean>());This method has the same behavior as the JDK 6 method
Collections.newSetFromMap()
. The returned set is serializable if
the backing map is.
map
- the backing map
IllegalArgumentException
- if map is not empty
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |