mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Merge "Create a singleton HashMap instead of using Collections.singleton()" into ub-launcher3-master
This commit is contained in:
committed by
Android (Google) Code Review
commit
c6444eef17
@@ -60,6 +60,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -652,4 +653,14 @@ public final class Utilities {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HashSet with a single element. We use this instead of Collections.singleton()
|
||||
* because HashSet ensures all operations, such as remove, are supported.
|
||||
*/
|
||||
public static <T> HashSet<T> singletonHashSet(T elem) {
|
||||
HashSet<T> hashSet = new HashSet<>(1);
|
||||
hashSet.add(elem);
|
||||
return hashSet;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user