Class Sets


  • public final class Sets
    extends Object
    Utility methods related to Sets.
    Author:
    alruiz
    • Constructor Detail

      • Sets

        private Sets()
    • Method Detail

      • newHashSet

        public static <T> 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> HashSet<T> newHashSet​(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> 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> 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> 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> 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.