mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
HashMap应指定初始长度
This commit is contained in:
parent
d53f1ff15e
commit
4f04bd121a
@ -179,7 +179,7 @@ public class CollStreamUtil {
|
||||
Set<K> key = new HashSet<>();
|
||||
key.addAll(map1.keySet());
|
||||
key.addAll(map2.keySet());
|
||||
Map<K, V> map = new HashMap<>();
|
||||
Map<K, V> map = MapUtil.newHashMap(key.size());
|
||||
for (K t : key) {
|
||||
X x = map1.get(t);
|
||||
Y y = map2.get(t);
|
||||
|
@ -7,12 +7,12 @@ import cn.hutool.core.math.Calculator;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -1362,8 +1362,8 @@ public class NumberUtil {
|
||||
throw new UtilException("Size is larger than range between begin and end!");
|
||||
}
|
||||
|
||||
Random ran = new Random();
|
||||
Set<Integer> set = new HashSet<>();
|
||||
SecureRandom ran = new SecureRandom();
|
||||
Set<Integer> set = new HashSet<>(Math.max((int) (size / .75f) + 1, 16));
|
||||
while (set.size() < size) {
|
||||
set.add(begin + ran.nextInt(end - begin));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user