java.lang.Object
br.com.objectos.collections.set.Sets
This class provides
static factory methods for the JDK
Set implementations.
This class is mainly provided as a convenience for Java Multi-Release codebases. In particular codebases that must support versions prior to Java 7 and, therefore, cannot use the diamond operator.
- Since:
- 2
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> HashSet<E>Returns a newHashSetinstance by invoking the constructor that takes no arguments.static <E> HashSet<E>newHashSet(Collection<? extends E> c) Returns a newHashSetinstance containing all of the distinct elements of the specified collection.static <E> HashSet<E>newHashSetWithCapacity(int initialCapacity) Returns a newHashSetinstance with the specified capacity.static <E> LinkedHashSet<E>Returns a newLinkedHashSetinstance by invoking the constructor that takes no arguments.static <E> LinkedHashSet<E>newLinkedHashSet(Collection<? extends E> c) Returns a newLinkedHashSetinstance containing all of the distinct elements of the specified collection.static <E> LinkedHashSet<E>newLinkedHashSetWithCapacity(int initialCapacity) Returns a newLinkedHashSetinstance with the specified capacity.static <E> TreeSet<E>Returns a newTreeSetinstance by invoking the constructor that takes no arguments.static <E> TreeSet<E>newTreeSet(Collection<? extends E> c) Returns a newTreeSetinstance containing all of the distinct elements of the specified collection.
-
Method Details
-
newHashSet
Returns a newHashSetinstance by invoking the constructor that takes no arguments. -
newHashSet
Returns a newHashSetinstance containing all of the distinct elements of the specified collection.- Type Parameters:
E- type of the elements in the set- Parameters:
c- construct the newHashSetwith all of the elements in this collection- Returns:
- a new
HashSetinstance - See Also:
-
newHashSetWithCapacity
Returns a newHashSetinstance with the specified capacity.- Type Parameters:
E- type of the elements in the set- Parameters:
initialCapacity- the initial capacity of the set's hash table- Returns:
- a new
HashSetinstance - See Also:
-
newLinkedHashSet
Returns a newLinkedHashSetinstance by invoking the constructor that takes no arguments.- Type Parameters:
E- type of the elements in the set- Returns:
- a new
LinkedHashSetinstance - See Also:
-
newLinkedHashSet
Returns a newLinkedHashSetinstance containing all of the distinct elements of the specified collection.- Type Parameters:
E- type of the elements in the set- Parameters:
c- construct the newLinkedHashSetwith all of the elements in this collection- Returns:
- a new
LinkedHashSetinstance - See Also:
-
newLinkedHashSetWithCapacity
Returns a newLinkedHashSetinstance with the specified capacity.- Type Parameters:
E- type of the elements in the set- Parameters:
initialCapacity- the initial capacity of the set's hash table- Returns:
- a new
LinkedHashSetinstance - See Also:
-
newTreeSet
Returns a newTreeSetinstance by invoking the constructor that takes no arguments. -
newTreeSet
Returns a newTreeSetinstance containing all of the distinct elements of the specified collection.- Type Parameters:
E- type of the elements in the set- Parameters:
c- construct the newTreeSetwith all of the elements in this collection- Returns:
- a new
TreeSetinstance - See Also:
-