java.lang.Object
br.com.objectos.collections.set.Sets

public final class Sets extends Object
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 Details

    • newHashSet

      public static <E> HashSet<E> newHashSet()
      Returns a new HashSet instance by invoking the constructor that takes no arguments.
      Type Parameters:
      E - type of the elements in the set
      Returns:
      a new HashSet instance
      See Also:
    • newHashSet

      public static <E> HashSet<E> newHashSet(Collection<? extends E> c)
      Returns a new HashSet instance containing all of the distinct elements of the specified collection.
      Type Parameters:
      E - type of the elements in the set
      Parameters:
      c - construct the new HashSet with all of the elements in this collection
      Returns:
      a new HashSet instance
      See Also:
    • newHashSetWithCapacity

      public static <E> HashSet<E> newHashSetWithCapacity(int initialCapacity)
      Returns a new HashSet instance 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 HashSet instance
      See Also:
    • newLinkedHashSet

      public static <E> LinkedHashSet<E> newLinkedHashSet()
      Returns a new LinkedHashSet instance by invoking the constructor that takes no arguments.
      Type Parameters:
      E - type of the elements in the set
      Returns:
      a new LinkedHashSet instance
      See Also:
    • newLinkedHashSet

      public static <E> LinkedHashSet<E> newLinkedHashSet(Collection<? extends E> c)
      Returns a new LinkedHashSet instance containing all of the distinct elements of the specified collection.
      Type Parameters:
      E - type of the elements in the set
      Parameters:
      c - construct the new LinkedHashSet with all of the elements in this collection
      Returns:
      a new LinkedHashSet instance
      See Also:
    • newLinkedHashSetWithCapacity

      public static <E> LinkedHashSet<E> newLinkedHashSetWithCapacity(int initialCapacity)
      Returns a new LinkedHashSet instance 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 LinkedHashSet instance
      See Also:
    • newTreeSet

      public static <E> TreeSet<E> newTreeSet()
      Returns a new TreeSet instance by invoking the constructor that takes no arguments.
      Type Parameters:
      E - type of the elements in the set
      Returns:
      a new TreeSet instance
      See Also:
    • newTreeSet

      public static <E> TreeSet<E> newTreeSet(Collection<? extends E> c)
      Returns a new TreeSet instance containing all of the distinct elements of the specified collection.
      Type Parameters:
      E - type of the elements in the set
      Parameters:
      c - construct the new TreeSet with all of the elements in this collection
      Returns:
      a new TreeSet instance
      See Also: