|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.SetUtil
public final class SetUtil
Provides static utility methods for Sets.
Every method comes in two versions. Tne first type takes SortedSet args, and preserves the sortedness in the result, which is always a NavigableSet instance. The second type takes arbitrary Sets.
Every method returns a new Set instance, and never modifies any of its args.
This class is multithread safe: it is stateless.
Nested Class Summary | |
---|---|
static class |
SetUtil.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Constructor Summary | |
---|---|
private |
SetUtil()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability. |
Method Summary | ||
---|---|---|
static
|
difference(Set<? extends T> set1,
Set<? extends T> set2)
Returns a new Set instance that is the difference of set1 and set2 (i.e. every element of set1 that is not in set2). |
|
private static
|
difference(Set<? extends T> set1,
Set<? extends T> set2,
Set<T> target)
|
|
static
|
difference(SortedSet<T> set1,
SortedSet<T> set2)
Returns a new NavigableSet instance that is the difference of set1 and set2 (i.e. every element of set1 that is not in set2). |
|
static
|
intersection(Set<? extends T> set1,
Set<? extends T> set2)
Returns a new Set instance that is the intersection of set1 and set2 (i.e. every element that is in both set1 and set2). |
|
private static
|
intersection(Set<? extends T> set1,
Set<? extends T> set2,
Set<T> target)
|
|
static
|
intersection(SortedSet<T> set1,
SortedSet<T> set2)
Returns a new NavigableSet instance that is the intersection of set1 and set2 (i.e. every element that is in both set1 and set2). |
|
static
|
union(Set<? extends T> set1,
Set<? extends T> set2)
Returns a new Set instance that is the union of set1 and set2 (i.e. every element that is in either set1 or set2). |
|
private static
|
union(Set<? extends T> set1,
Set<? extends T> set2,
Set<T> target)
|
|
static
|
union(SortedSet<T> set1,
SortedSet<T> set2)
Returns a new NavigableSet instance that is the union of set1 and set2 (i.e. every element that is in either set1 or set2). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private SetUtil()
Method Detail |
---|
public static <T extends Comparable> NavigableSet<T> union(SortedSet<T> set1, SortedSet<T> set2) throws IllegalArgumentException
The args set1 and set2 are two SortedSets that share the same Comparable element type. The result is a NavigableSet of the same element type.
IllegalArgumentException
- if set1 == null; set2 == nullpublic static <T> Set<T> union(Set<? extends T> set1, Set<? extends T> set2) throws IllegalArgumentException
The args set1 and set2 may be any type of Set class. The element type of the result is the most specific common superclass of set1 and set2.
IllegalArgumentException
- if set1 == null; set2 == nullprivate static <T> Set<T> union(Set<? extends T> set1, Set<? extends T> set2, Set<T> target) throws IllegalArgumentException
IllegalArgumentException
public static <T extends Comparable> NavigableSet<T> intersection(SortedSet<T> set1, SortedSet<T> set2) throws IllegalArgumentException
The args set1 and set2 are two SortedSets that share the same Comparable element type. The result is a NavigableSet of the same element type.
IllegalArgumentException
- if set1 == null; set2 == nullpublic static <T> Set<T> intersection(Set<? extends T> set1, Set<? extends T> set2) throws IllegalArgumentException
The args set1 and set2 may be any type of Set class. The element type of the result is the most specific common superclass of set1 and set2.
IllegalArgumentException
- if set1 == null; set2 == nullprivate static <T> Set<T> intersection(Set<? extends T> set1, Set<? extends T> set2, Set<T> target) throws IllegalArgumentException
IllegalArgumentException
public static <T extends Comparable> NavigableSet<T> difference(SortedSet<T> set1, SortedSet<T> set2) throws IllegalArgumentException
The args set1 and set2 are two SortedSets that share the same Comparable element type. The result is a NavigableSet of the same element type.
IllegalArgumentException
- if set1 == null; set2 == nullpublic static <T> Set<T> difference(Set<? extends T> set1, Set<? extends T> set2) throws IllegalArgumentException
The args set1 and set2 may be any type of Set class. The element type of the result is the most specific common superclass of set1 and set2.
IllegalArgumentException
- if set1 == null; set2 == nullprivate static <T> Set<T> difference(Set<? extends T> set1, Set<? extends T> set2, Set<T> target) throws IllegalArgumentException
IllegalArgumentException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |