Class Sets
- java.lang.Object
-
- org.glassfish.jersey.internal.guava.Sets
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> HashSet<E>newHashSet()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 Detail
-
newHashSet
public static <E> HashSet<E> 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
public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
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
-
unmodifiableNavigableSet
public static <E> NavigableSet<E> unmodifiableNavigableSet(NavigableSet<E> set)
Returns an unmodifiable view of the specified navigable set. This method allows modules to provide users with "read-only" access to internal navigable sets. Query operations on the returned set "read through" to the specified set, and attempts to modify the returned set, whether direct or via its collection views, result in anUnsupportedOperationException.The returned navigable set will be serializable if the specified navigable set is serializable.
- Parameters:
set- the navigable set for which an unmodifiable view is to be returned- Returns:
- an unmodifiable view of the specified navigable set
- Since:
- 12.0
-
-