mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Handy method for creating sets
This commit is contained in:
@@ -29,6 +29,7 @@ import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
|
||||
public class ContainerUtil {
|
||||
private static final int INSERTION_SORT_THRESHOLD = 10;
|
||||
|
||||
@@ -741,6 +742,16 @@ public class ContainerUtil {
|
||||
return Arrays.asList(items);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Set<T> set(@Nullable T... items) {
|
||||
@SuppressWarnings({"UnnecessaryFullyQualifiedName"})
|
||||
final Set<T> set = new java.util.HashSet<T>();
|
||||
if (items != null) {
|
||||
set.addAll(Arrays.asList(items));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
// Generalized Quick Sort. Does neither array.clone() nor list.toArray()
|
||||
public static <T> void quickSort(List<T> list, Comparator<? super T> comparator) {
|
||||
quickSort(list, comparator, 0, list.size());
|
||||
|
||||
Reference in New Issue
Block a user