public final class NavigableSets extends Object
NavigableSet
.Modifier and Type | Method and Description |
---|---|
static <E> NavigableSet<E> |
difference(NavigableSet<E> set1,
NavigableSet<E> set2)
Create a read-only view of the difference of two
NavigableSet s that have a consistent sort order. |
static <E> NavigableSet<E> |
empty()
Create an empty
NavigableSet . |
static <E> NavigableSet<E> |
empty(Comparator<? super E> comparator)
Create an empty
NavigableSet with a specified Comparator . |
static <E> NavigableSet<E> |
intersection(Iterable<? extends NavigableSet<E>> sets)
Create a read-only view of the intersection of two or more
NavigableSet s that have a consistent sort order. |
static <E> NavigableSet<E> |
intersection(NavigableSet<E>... sets)
Create a read-only view of the intersection of two or more
NavigableSet s that have a consistent sort order. |
static <E> NavigableSet<E> |
singleton(Comparator<? super E> comparator,
E value)
Create a
NavigableSet containing a single element. |
static <E> NavigableSet<E> |
singleton(E value)
Create a
NavigableSet containing a single element and natural ordering. |
static <E> NavigableSet<E> |
symmetricDifference(NavigableSet<E> set1,
NavigableSet<E> set2)
Create a read-only view of the symmetric difference of two
NavigableSet s that have a consistent sort order. |
static <E> NavigableSet<E> |
union(Iterable<? extends NavigableSet<E>> sets)
Create a read-only view of the union of two or more
NavigableSet s that have a consistent sort order. |
static <E> NavigableSet<E> |
union(NavigableSet<E>... sets)
Create a read-only view of the union of two or more
NavigableSet s that have a consistent sort order. |
public static <E> NavigableSet<E> intersection(Iterable<? extends NavigableSet<E>> sets)
NavigableSet
s that have a consistent sort order.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).
The returned intersection iterates efficiently: a complete iteration requires O(N * M) queries, where N is the size of the smallest set, and M is the number of sets.
E
- element typesets
- the sets to intersectsets
IllegalArgumentException
- if the sets
do not have equal Comparator
sIllegalArgumentException
- if sets
, or any NavigableSet
therein, is null@SafeVarargs public static <E> NavigableSet<E> intersection(NavigableSet<E>... sets)
NavigableSet
s that have a consistent sort order.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).
The returned intersection iterates efficiently: a complete iteration takes time O(N * M) where N is the size of the smallest set, and M is the number of sets.
E
- element typesets
- the sets to intersectsets
IllegalArgumentException
- if the sets
do not have equal Comparator
sIllegalArgumentException
- if sets
, or any NavigableSet
therein, is null@SafeVarargs public static <E> NavigableSet<E> union(NavigableSet<E>... sets)
NavigableSet
s that have a consistent sort order.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).E
- element typesets
- the sets to unionsets
IllegalArgumentException
- if the sets
do not have equal Comparator
sIllegalArgumentException
- if sets
, or any NavigableSet
therein, is nullpublic static <E> NavigableSet<E> union(Iterable<? extends NavigableSet<E>> sets)
NavigableSet
s that have a consistent sort order.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).E
- element typesets
- the sets to unionsets
IllegalArgumentException
- if the sets
do not have equal Comparator
sIllegalArgumentException
- if sets
, or any NavigableSet
therein, is nullpublic static <E> NavigableSet<E> difference(NavigableSet<E> set1, NavigableSet<E> set2)
NavigableSet
s that have a consistent sort order.
That is, a set containing all elements contained in the first set but not the second.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).E
- element typeset1
- original setset2
- set of elements to exclude from set1
set1
and set2
IllegalArgumentException
- if the set1
and set2
do not have equal Comparator
sIllegalArgumentException
- if either parameter is is nullpublic static <E> NavigableSet<E> symmetricDifference(NavigableSet<E> set1, NavigableSet<E> set2)
NavigableSet
s that have a consistent sort order.
That is, the set containing all elements contained in the first set or the second set, but not in both sets.
The Comparators of the sets must all be equal
(or else all null, for natural ordering).E
- element typeset1
- first setset2
- second setset1
and set2
IllegalArgumentException
- if the set1
and set2
do not have equal Comparator
sIllegalArgumentException
- if either parameter is is nullpublic static <E> NavigableSet<E> singleton(E value)
NavigableSet
containing a single element and natural ordering.E
- element typevalue
- singleton valueIllegalArgumentException
- if value
is null or
value
's class has no natural ordering (i.e., does not implement Comparable
)public static <E> NavigableSet<E> singleton(Comparator<? super E> comparator, E value)
NavigableSet
containing a single element.E
- element typecomparator
- comparator, or null for natural orderingvalue
- singleton value (possibly null)IllegalArgumentException
- if comparator
is null and either value
is null or
value
's class has no natural ordering (i.e., does not implement Comparable
)public static <E> NavigableSet<E> empty()
NavigableSet
.
The returned set's comparator()
method will return null.E
- element typepublic static <E> NavigableSet<E> empty(Comparator<? super E> comparator)
NavigableSet
with a specified Comparator
.E
- element typecomparator
- comparator, or null for natural orderingCopyright © 2019. All rights reserved.