|
|
|
|
@ -85,8 +85,7 @@ public abstract class CollectionUtils {
@@ -85,8 +85,7 @@ public abstract class CollectionUtils {
|
|
|
|
|
* @see #newLinkedHashMap(int) |
|
|
|
|
*/ |
|
|
|
|
public static <K, V> HashMap<K, V> newHashMap(int expectedSize) { |
|
|
|
|
int capacity = (int) Math.ceil(expectedSize / (double) DEFAULT_LOAD_FACTOR); |
|
|
|
|
return new HashMap<>(capacity, DEFAULT_LOAD_FACTOR); |
|
|
|
|
return new HashMap<>(computeMapInitialCapacity(expectedSize), DEFAULT_LOAD_FACTOR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -103,8 +102,11 @@ public abstract class CollectionUtils {
@@ -103,8 +102,11 @@ public abstract class CollectionUtils {
|
|
|
|
|
* @see #newHashMap(int) |
|
|
|
|
*/ |
|
|
|
|
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int expectedSize) { |
|
|
|
|
int capacity = (int) Math.ceil(expectedSize / (double) DEFAULT_LOAD_FACTOR); |
|
|
|
|
return new LinkedHashMap<>(capacity, DEFAULT_LOAD_FACTOR); |
|
|
|
|
return new LinkedHashMap<>(computeMapInitialCapacity(expectedSize), DEFAULT_LOAD_FACTOR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static int computeMapInitialCapacity(int expectedSize) { |
|
|
|
|
return (int) Math.ceil(expectedSize / (double) DEFAULT_LOAD_FACTOR); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|