util: LinkedHashMap from pairs

This commit is contained in:
Roman Shevchenko
2013-11-27 21:06:03 +01:00
parent 4d5bfb7bdd
commit 80d5bcb936
2 changed files with 18 additions and 2 deletions
@@ -61,7 +61,8 @@ public class ContainerUtilRt {
return map;
}
public static <K, V> Map<K,V> newHashMap(Pair<K, V> first, Pair<K, V>[] entries) {
@NotNull
public static <K, V> Map<K,V> newHashMap(@NotNull Pair<K, V> first, Pair<K, V>[] entries) {
Map<K, V> map = newHashMap();
map.put(first.getFirst(), first.getSecond());
for (Pair<K, V> entry : entries) {
@@ -90,6 +91,16 @@ public class ContainerUtilRt {
return new com.intellij.util.containers.LinkedHashMap<K, V>(map);
}
@NotNull
public static <K, V> LinkedHashMap<K,V> newLinkedHashMap(@NotNull Pair<K, V> first, Pair<K, V>[] entries) {
LinkedHashMap<K, V> map = newLinkedHashMap();
map.put(first.getFirst(), first.getSecond());
for (Pair<K, V> entry : entries) {
map.put(entry.getFirst(), entry.getSecond());
}
return map;
}
@NotNull
public static <T> LinkedList<T> newLinkedList() {
return new LinkedList<T>();
@@ -55,7 +55,7 @@ public class ContainerUtil extends ContainerUtilRt {
}
@NotNull
public static <K, V> Map<K, V> newHashMap(Pair<K, V> first, Pair<K, V>... entries) {
public static <K, V> Map<K, V> newHashMap(@NotNull Pair<K, V> first, Pair<K, V>... entries) {
return ContainerUtilRt.newHashMap(first, entries);
}
@@ -84,6 +84,11 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newLinkedHashMap(map);
}
@NotNull
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(@NotNull Pair<K, V> first, Pair<K, V>... entries) {
return ContainerUtilRt.newLinkedHashMap(first, entries);
}
@NotNull
public static <K, V> THashMap<K, V> newTroveMap() {
return new THashMap<K, V>();