java.lang.Object
org.elasticsearch.common.util.set.Sets
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> Set<E>
Creates a copy of the given set and adds extra element.static <E> Set<E>
Creates a copy of the given set and adds extra elements.static <T> Set<T>
difference
(Set<T> left, Set<T> right) The relative complement, or difference, of the specified left and right set.static <T> boolean
haveEmptyIntersection
(Set<T> left, Set<T> right) static <T> boolean
haveNonEmptyIntersection
(Set<T> left, Set<T> right) static <T> Set<T>
intersection
(Set<T> set1, Set<T> set2) The intersection of two sets.static <T> Set<T>
static <T> HashSet<T>
newHashSet
(Iterable<T> iterable) static <T> HashSet<T>
newHashSet
(Iterator<T> iterator) static <T> HashSet<T>
newHashSet
(T... elements) static <E> Set<E>
newHashSetWithExpectedSize
(int expectedSize) static <E> LinkedHashSet<E>
newLinkedHashSetWithExpectedSize
(int expectedSize) static <T> SortedSet<T>
sortedDifference
(Set<T> left, Set<T> right) The relative complement, or difference, of the specified left and right set, returned as a sorted set.Returns aCollector
that accumulates the input elements into a sorted set.Returns aCollector
that accumulates the input elements into a sorted set and finishes the resulting set into an unmodifiable set.static <T> Set<T>
static <T> SortedSet<T>
unmodifiableSortedDifference
(Set<T> left, Set<T> right) The relative complement, or difference, of the specified left and right set, returned as a sorted set.
-
Method Details
-
newHashSet
-
newHashSet
-
newHashSet
-
newHashSetWithExpectedSize
-
newLinkedHashSetWithExpectedSize
-
newConcurrentHashSet
-
haveEmptyIntersection
-
haveNonEmptyIntersection
-
difference
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
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
-
unmodifiableSortedDifference
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. The resulting set is unmodifiable.- Type Parameters:
T
- the type of the elements of the sets- Parameters:
left
- the left setright
- the right set- Returns:
- the unmodifiable sorted relative complement of the left set with respect to the right set
-
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
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
-
intersection
The intersection of two sets. Namely, the resulting set contains all the elements that are in both sets. Neither input is mutated by this operation, an entirely new set is returned.- Parameters:
set1
- the first setset2
- the second set- Returns:
- the unmodifiable intersection of the two sets
-
addToCopy
Creates a copy of the given set and adds extra element.- Parameters:
set
- set to copyelement
- element to add
-
addToCopy
Creates a copy of the given set and adds extra elements.- Parameters:
set
- set to copyelements
- elements to add
-