Class Sets
java.lang.Object
org.glassfish.jersey.internal.guava.Sets
Static utility methods pertaining to
Set
instances. Also see this
class's counterparts Lists
, Maps
and Queues
.
See the Guava User Guide article on
Sets
.
- Since:
- 2.0 (imported from Google Collections Library)
- Author:
- Kevin Bourrillion, Jared Levy, Chris Povirk
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> HashSet<E>
Creates a mutable, emptyHashSet
instance.static <E> HashSet<E>
newHashSetWithExpectedSize
(int expectedSize) Creates aHashSet
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth.static <E> NavigableSet<E>
unmodifiableNavigableSet
(NavigableSet<E> set) Returns an unmodifiable view of the specified navigable set.
-
Method Details
-
newHashSet
Creates a mutable, emptyHashSet
instance.Note: if mutability is not required, use
ImmutableSet#of()
instead.Note: if
E
is anEnum
type, useEnumSet.noneOf(java.lang.Class<E>)
instead.- Returns:
- a new, empty
HashSet
-
newHashSetWithExpectedSize
Creates aHashSet
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.6. It also can't be guaranteed that the method isn't inadvertently oversizing the returned set.- Parameters:
expectedSize
- the number of elements you expect to add to the returned set- Returns:
- a new, empty
HashSet
with enough capacity to holdexpectedSize
elements without resizing - Throws:
IllegalArgumentException
- ifexpectedSize
is negative
-