Class Sets
java.lang.Object
org.elasticsearch.common.util.set.Sets
public final class Sets
extends java.lang.Object
-
Method Summary
Modifier and Type Method Description static <T> java.util.Set<T>
difference(java.util.Set<T> left, java.util.Set<T> right)
The relative complement, or difference, of the specified left and right set.static <T> boolean
haveEmptyIntersection(java.util.Set<T> left, java.util.Set<T> right)
static <T> boolean
haveNonEmptyIntersection(java.util.Set<T> left, java.util.Set<T> right)
static <T> java.util.Set<T>
intersection(java.util.Set<T> set1, java.util.Set<T> set2)
static <T> java.util.Set<T>
newConcurrentHashSet()
static <T> java.util.HashSet<T>
newHashSet(java.lang.Iterable<T> iterable)
static <T> java.util.HashSet<T>
newHashSet(java.util.Iterator<T> iterator)
static <T> java.util.HashSet<T>
newHashSet(T... elements)
static <T> java.util.SortedSet<T>
sortedDifference(java.util.Set<T> left, java.util.Set<T> right)
The relative complement, or difference, of the specified left and right set, returned as a sorted set.static <T> java.util.stream.Collector<T,java.util.SortedSet<T>,java.util.SortedSet<T>>
toSortedSet()
Returns aCollector
that accumulates the input elements into a sorted set.static <T> java.util.stream.Collector<T,java.util.SortedSet<T>,java.util.SortedSet<T>>
toUnmodifiableSortedSet()
Returns aCollector
that accumulates the input elements into a sorted set and finishes the resulting set into an unmodifiable set.static <T> java.util.Set<T>
union(java.util.Set<T> left, java.util.Set<T> right)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
newHashSet
public static <T> java.util.HashSet<T> newHashSet(java.util.Iterator<T> iterator) -
newHashSet
public static <T> java.util.HashSet<T> newHashSet(java.lang.Iterable<T> iterable) -
newHashSet
public static <T> java.util.HashSet<T> newHashSet(T... elements) -
newConcurrentHashSet
public static <T> java.util.Set<T> newConcurrentHashSet() -
haveEmptyIntersection
public static <T> boolean haveEmptyIntersection(java.util.Set<T> left, java.util.Set<T> right) -
haveNonEmptyIntersection
public static <T> boolean haveNonEmptyIntersection(java.util.Set<T> left, java.util.Set<T> right) -
difference
public static <T> java.util.Set<T> difference(java.util.Set<T> left, java.util.Set<T> right)The relative complement, or difference, of the specified left and right set. Namely, the resulting set contains all the elements that are in the left set but not in the right set. Neither input is mutated by this operation, an entirely new set is returned.- Type Parameters:
T
- the type of the elements of the sets- Parameters:
left
- the left setright
- the right set- Returns:
- the relative complement of the left set with respect to the right set
-
sortedDifference
public static <T> java.util.SortedSet<T> sortedDifference(java.util.Set<T> left, java.util.Set<T> right)The relative complement, or difference, of the specified left and right set, returned as a sorted set. Namely, the resulting set contains all the elements that are in the left set but not in the right set, and the set is sorted using the natural ordering of element type. Neither input is mutated by this operation, an entirely new set is returned.- Type Parameters:
T
- the type of the elements of the sets- Parameters:
left
- the left setright
- the right set- Returns:
- the sorted relative complement of the left set with respect to the right set
-
toSortedSet
public static <T> java.util.stream.Collector<T,java.util.SortedSet<T>,java.util.SortedSet<T>> toSortedSet()Returns aCollector
that accumulates the input elements into a sorted set.- Type Parameters:
T
- the type of the input elements- Returns:
- a sorted set
-
toUnmodifiableSortedSet
public static <T> java.util.stream.Collector<T,java.util.SortedSet<T>,java.util.SortedSet<T>> toUnmodifiableSortedSet()Returns aCollector
that accumulates the input elements into a sorted set and finishes the resulting set into an unmodifiable set. The resulting read-only view through the unmodifiable set is a sorted set.- Type Parameters:
T
- the type of the input elements- Returns:
- an unmodifiable set where the underlying set is sorted
-
union
public static <T> java.util.Set<T> union(java.util.Set<T> left, java.util.Set<T> right) -
intersection
public static <T> java.util.Set<T> intersection(java.util.Set<T> set1, java.util.Set<T> set2)
-