Class Sets


  • public final class Sets
    extends java.lang.Object
    Utility methods related to Sets.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Sets()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.HashSet<T> newHashSet()
      Creates a mutable HashSet.
      static <T> java.util.HashSet<T> newHashSet​(java.lang.Iterable<? extends T> elements)
      Creates a mutable HashSet containing the given elements.
      static <T> java.util.LinkedHashSet<T> newLinkedHashSet()
      Creates a mutable LinkedHashSet.
      static <T> java.util.LinkedHashSet<T> newLinkedHashSet​(T... elements)
      Creates a mutable LinkedHashSet containing the given elements.
      static <T> java.util.TreeSet<T> newTreeSet()
      Creates a mutable TreeSet.
      static <T> java.util.TreeSet<T> newTreeSet​(T... elements)
      Creates a mutable TreeSet containing the given elements.
      static <T> java.util.Set<T> set​(T... elements)
      Creates a mutable LinkedHashSet containing the given elements.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Sets

        private Sets()
    • Method Detail

      • set

        @SafeVarargs
        public static <T> java.util.Set<T> set​(T... elements)
        Creates a mutable LinkedHashSet containing the given elements.
        Type Parameters:
        T - the generic type of the HashSet to create.
        Parameters:
        elements - the elements to store in the HashSet.
        Returns:
        the created HashSet, or null if the given array of elements is null.
      • newHashSet

        public static <T> java.util.HashSet<T> newHashSet()
        Creates a mutable HashSet.
        Type Parameters:
        T - the generic type of the HashSet to create.
        Returns:
        the created HashSet.
      • newHashSet

        public static <T> java.util.HashSet<T> newHashSet​(java.lang.Iterable<? extends T> elements)
        Creates a mutable HashSet containing the given elements.
        Type Parameters:
        T - the generic type of the HashSet to create.
        Parameters:
        elements - the elements to store in the HashSet.
        Returns:
        the created HashSet, or null if the given array of elements is null.
      • newLinkedHashSet

        public static <T> java.util.LinkedHashSet<T> newLinkedHashSet()
        Creates a mutable LinkedHashSet.
        Type Parameters:
        T - the generic type of the LinkedHashSet to create.
        Returns:
        the created LinkedHashSet.
      • newLinkedHashSet

        @SafeVarargs
        public static <T> java.util.LinkedHashSet<T> newLinkedHashSet​(T... elements)
        Creates a mutable LinkedHashSet containing the given elements.
        Type Parameters:
        T - the generic type of the LinkedHashSet to create.
        Parameters:
        elements - the elements to store in the LinkedHashSet.
        Returns:
        the created LinkedHashSet, or null if the given array of elements is null.
      • newTreeSet

        public static <T> java.util.TreeSet<T> newTreeSet()
        Creates a mutable TreeSet.
        Type Parameters:
        T - the generic type of the TreeSet to create.
        Returns:
        the created TreeSet.
      • newTreeSet

        @SafeVarargs
        public static <T> java.util.TreeSet<T> newTreeSet​(T... elements)
        Creates a mutable TreeSet containing the given elements.
        Type Parameters:
        T - the generic type of the TreeSet to create.
        Parameters:
        elements - the elements to store in the TreeSet.
        Returns:
        the created TreeSet, or null if the given array of elements is null.