Class Sets
java.lang.Object
org.glassfish.jersey.internal.guava.Sets
-
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
instead.invalid reference
ImmutableSet#of()Note: if
Eis anEnumtype, useEnumSet.noneOf(Class)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
-