Create an immutable set that sorts its elements in natural order
(T... values)
| 40 | |
| 41 | /** Create an immutable set that sorts its elements in natural order */ |
| 42 | @SafeVarargs |
| 43 | public static <T extends Comparable<T>> Set<T> sortedSetOf(T... values) { |
| 44 | Set<T> set = new TreeSet<>(); |
| 45 | addAll(set, values); |
| 46 | return unmodifiableSet(set); |
| 47 | } |
| 48 | |
| 49 | /** Collects a stream into an immutable set sorted in natural order */ |
| 50 | public static <T extends Comparable<? super T>> Collector<T, ?, Set<T>> toSortedSet() { |