public final class Sets extends Object
com.google.common.collect.Sets.| Modifier and Type | Field and Description |
|---|---|
private static int |
THIRD
Capacity ratio.
|
| Modifier | Constructor and Description |
|---|---|
private |
Sets()
Hidden for pure static factory.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) static int |
capacity(int expectedSize)
Returns a capacity that is sufficient to keep the map from being resized as long as it grows no larger than
expectedSize and the load factor is >= its default (0.75).
|
static <E> Set<E> |
newHashSet()
Creates a new hash set.
|
static <E> Set<E> |
newHashSet(E... elements)
Creates a mutable
HashSet instance containing the given elements in unspecified order. |
static <E> Set<E> |
newHashSetWithExpectedSize(int expectedSize)
Creates a
HashSet instance, with a high enough "initial capacity" that it should hold
expectedSize elements without growth. |
static <E> SortedSet<E> |
newTreeSet()
Creates a new tree set.
|
private static final int THIRD
static int capacity(int expectedSize)
expectedSize - must not be negativepublic static <E> Set<E> newHashSet()
E - type of elementsnull, always new instancepublic static <E> Set<E> newHashSet(E... elements)
HashSet instance containing the given elements in unspecified order.E - type of elementselements - the elements that the set should containHashSet containing those elements (minus duplicates)public static <E> Set<E> newHashSetWithExpectedSize(int expectedSize)
HashSet instance, with a high enough "initial capacity" that it should hold
expectedSize 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.
E - type of elementsexpectedSize - the number of elements you expect to add to the returned setHashSet with enough capacity to hold expectedSize elements without resizing
//CHECKSTYLE:OFFIllegalArgumentException - if expectedSize is negative
//CHECKSTYLE:ONpublic static <E> SortedSet<E> newTreeSet()
E - type of elementsnull, always new instanceCopyright © 2014 Sven Strittmatter. All Rights Reserved.