summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-09 21:59:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-09 21:59:47 +0000
commitc6444eef17c472629b17bd7ca0da4bcb95cf5959 (patch)
treee9ac69fa8c2081bb8122c6ec21ab4e2bff2282f9 /src/com/android/launcher3/Utilities.java
parentc9f844db2b54e17c562736f9fdb54202c2ad6d1a (diff)
parent580edcf529b0755f2bba442e97dd02d8cdad3b82 (diff)
downloadandroid_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.tar.gz
android_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.tar.bz2
android_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.zip
Merge "Create a singleton HashMap instead of using Collections.singleton()" into ub-launcher3-master
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 839b5e85c..78774f3b8 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -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;
+ }
}