Class SetUtil


  • public final class SetUtil
    extends Object
    Utilities for working with sets using JDK 1.5 generics.
    • Method Detail

      • getSingleton

        public static <T> T getSingleton​(Set<T> s)
      • addArray

        public static <T> void addArray​(Set<T> set,
                                        T[] array)
      • newSet

        public static <T> Set<T> newSet()
      • newSet

        public static <T> Set<T> newSet​(T item)
        Create a new Set with one member.
      • copySet

        public static <T> HashSet<T> copySet​(Set<? extends T> s1)
        Create a new Set containing all members of another. The returned Set is always a HashSet.
      • newSet

        public static <T> Set<? extends T> newSet​(T m1,
                                                  T m2)
      • newSet

        public static <T> Set<T> newSet​(T m1,
                                        T m2,
                                        T m3,
                                        T m4)
      • newSet

        public static <T> Set<T> newSet​(T[] objects)
        Create a new Set containing all array elements.
      • newSet

        public static <T,​TT extends T> Set<T> newSet​(Set<T> s1,
                                                           Set<TT> s2)
      • newSet

        public static <T> Set<T> newSet​(T[] objects,
                                        int startIndex,
                                        int numItems)
        Create a new Set containing all array elements.
      • toStringArray

        public static String[] toStringArray​(Set<?> s)
        Convert a Set to a String[]
      • toSortedStringArray

        public static String[] toSortedStringArray​(Set<?> s)
      • newStringSet

        public static Set<String> newStringSet​(String... args)
      • newUnmodifiableSet

        public static <T> Set<T> newUnmodifiableSet​(T... args)
      • newUnmodifiableStringSet

        public static Set<String> newUnmodifiableStringSet​(String... args)
      • newTypedSet

        public static <T> Set<T> newTypedSet​(T... args)
      • newSingletonSet

        public static <T> Set<T> newSingletonSet​(T m1)
        Create a new Set with one member. Additional items may be added.
      • intersectSets

        public static <T> Set<T> intersectSets​(Set<T> set1,
                                               Set<T> set2)
        Return a new Set of all items in both set1 and set2.
      • removeSet

        public static <T> Set<T> removeSet​(Set<T> set1,
                                           Set<T> set2)
        Return a new Set of all items in set1 not in set2.
      • newNotCommonSet

        public static <T> Set<T> newNotCommonSet​(Set<T> set1,
                                                 Set<T> set2)
        Return a new Set of all items not common to both sets.