# Class Sets

java.lang.Object
org.elasticsearch.common.util.set.Sets

public final class Sets extends Object
• ## Method Summary

Modifier and Type
Method
Description
`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)```

`static <T> Set<T>`
`newConcurrentHashSet()`

`static <T> HashSet<T>`
`newHashSet(Iterable<T> iterable)`

`static <T> HashSet<T>`
`newHashSet(Iterator<T> iterator)`

`static <T> HashSet<T>`
`newHashSet(T... elements)`

`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.
`static <T> Collector<T,SortedSet<T>,SortedSet<T>>`
`toSortedSet()`
Returns a `Collector` that accumulates the input elements into a sorted set.
`static <T> Collector<T,SortedSet<T>,SortedSet<T>>`
`toUnmodifiableSortedSet()`
Returns a `Collector` that accumulates the input elements into a sorted set and finishes the resulting set into an unmodifiable set.
`static <T> Set<T>`
```union(Set<T> left, 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> HashSet<T> newHashSet(Iterator<T> iterator)
• ### newHashSet

public static <T> HashSet<T> newHashSet(Iterable<T> iterable)
• ### newHashSet

public static <T> HashSet<T> newHashSet(T... elements)
• ### newConcurrentHashSet

public static <T> Set<T> newConcurrentHashSet()
• ### haveEmptyIntersection

public static <T> boolean haveEmptyIntersection(Set<T> left, Set<T> right)
• ### haveNonEmptyIntersection

public static <T> boolean haveNonEmptyIntersection(Set<T> left, Set<T> right)
• ### difference

public static <T> Set<T> difference(Set<T> left, 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 set
`right` - the right set
Returns:
the relative complement of the left set with respect to the right set
• ### sortedDifference

public 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. 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 set
`right` - the right set
Returns:
the sorted relative complement of the left set with respect to the right set
• ### toSortedSet

public static <T> Collector<T,SortedSet<T>,SortedSet<T>> toSortedSet()
Returns a `Collector` 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> Collector<T,SortedSet<T>,SortedSet<T>> toUnmodifiableSortedSet()
Returns a `Collector` 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> Set<T> union(Set<T> left, Set<T> right)
• ### intersection

public static <T> Set<T> intersection(Set<T> set1, Set<T> set2)
{"ft_lang_label":"__label__en","ft_lang_prob":0.62126595,"math_prob":0.5866021,"size":2596,"snap":"2023-14-2023-23","text_gpt3_token_len":604,"char_repetition_ratio":0.15470679,"word_repetition_ratio":0.5435898,"special_character_ratio":0.21109399,"punctuation_ratio":0.12107623,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96500146,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-06-03T21:02:40Z\",\"WARC-Record-ID\":\"<urn:uuid:944af5a1-2ea1-482c-9603-b214d2dc1be7>\",\"Content-Length\":\"32444\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:a5af45d0-522d-40e1-9f6b-689392c5b354>\",\"WARC-Concurrent-To\":\"<urn:uuid:08d40625-b7c2-42a5-80cb-e4b1f8af1fad>\",\"WARC-IP-Address\":\"34.120.127.130\",\"WARC-Target-URI\":\"https://artifacts.elastic.co/javadoc/org/elasticsearch/elasticsearch/7.17.6/org/elasticsearch/common/util/set/Sets.html\",\"WARC-Payload-Digest\":\"sha1:WVXTYSVSYZGALMYPE2HYRJJ5BTGILLFY\",\"WARC-Block-Digest\":\"sha1:KQ5FJGC4CHRDRVFZBVORKV6VKCSTBLRP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224649343.34_warc_CC-MAIN-20230603201228-20230603231228-00256.warc.gz\"}"}