Use Map.merge
This commit is contained in:
parent
7ed772e474
commit
9fcd3885dc
|
@ -80,11 +80,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
public EnumeratedIntegerDistribution(final int[] data) {
|
||||
final Map<Integer, Integer> dataMap = new HashMap<>();
|
||||
for (int value : data) {
|
||||
Integer count = dataMap.get(value);
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
}
|
||||
dataMap.put(value, ++count);
|
||||
dataMap.merge(value, 1, Integer::sum);
|
||||
}
|
||||
final int massPoints = dataMap.size();
|
||||
final double denom = data.length;
|
||||
|
|
|
@ -82,11 +82,7 @@ public class EnumeratedRealDistribution
|
|||
public EnumeratedRealDistribution(final double[] data) {
|
||||
final Map<Double, Integer> dataMap = new HashMap<>();
|
||||
for (double value : data) {
|
||||
Integer count = dataMap.get(value);
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
}
|
||||
dataMap.put(value, ++count);
|
||||
dataMap.merge(value, 1, Integer::sum);
|
||||
}
|
||||
final int massPoints = dataMap.size();
|
||||
final double denom = data.length;
|
||||
|
|
Loading…
Reference in New Issue