Here you can find the source of toSortedSet(Comparator
Parameter | Description |
---|---|
Value | the type of values |
comparator | the comparator |
values | more of the values |
@SafeVarargs public static <Value> SortedSet<Value> toSortedSet(Comparator<Value> comparator, Value... values)
//package com.java2s; //License from project: Open Source License import java.util.Comparator; import java.util.SortedSet; import java.util.TreeSet; public class Main { /**// www .j av a2 s.com * Create a set * * @param <Value> the type of values * @param comparator the comparator * @param values more of the values * @return the list */ @SafeVarargs public static <Value> SortedSet<Value> toSortedSet(Comparator<Value> comparator, Value... values) { SortedSet<Value> set = new TreeSet<>(comparator); if (values != null && values.length > 0) { for (Value value : values) { set.add(value); } } return set; } /** * Create a set * * @param <Value> the type of values * @param values more of the values * @return the list */ @SafeVarargs public static <Value extends Comparable<Value>> SortedSet<Value> toSortedSet(Value... values) { SortedSet<Value> set = new TreeSet<>(); if (values != null && values.length > 0) { for (Value value : values) { set.add(value); } } return set; } }