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, emptyHashSetinstance.static <E> HashSet<E>newHashSetWithExpectedSize(int expectedSize) Creates aHashSetinstance, with a high enough "initial capacity" that it should holdexpectedSizeelements 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, emptyHashSetinstance.Note: if mutability is not required, use
ImmutableSet#of()instead.Note: if
Eis anEnumtype, useEnumSet.noneOf(java.lang.Class<E>)instead.- Returns:
- a new, empty
HashSet
-
newHashSetWithExpectedSize
Creates aHashSetinstance, with a high enough "initial capacity" that it should holdexpectedSizeelements 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
HashSetwith enough capacity to holdexpectedSizeelements without resizing - Throws:
IllegalArgumentException- ifexpectedSizeis negative
-