use of java.util.IntSummaryStatistics in project jdk8u_jdk by JetBrains.
the class SummaryStatisticsTest method testIntStatistics.
public void testIntStatistics() {
List<IntSummaryStatistics> instances = new ArrayList<>();
instances.add(countTo(1000).stream().collect(Collectors.summarizingInt(i -> i)));
instances.add(countTo(1000).stream().mapToInt(i -> i).summaryStatistics());
instances.add(countTo(1000).parallelStream().collect(Collectors.summarizingInt(i -> i)));
instances.add(countTo(1000).parallelStream().mapToInt(i -> i).summaryStatistics());
for (IntSummaryStatistics stats : instances) {
assertEquals(stats.getCount(), 1000);
assertEquals(stats.getSum(), countTo(1000).stream().mapToInt(i -> i).sum());
assertEquals(stats.getMax(), 1000);
assertEquals(stats.getMin(), 1);
}
}
use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.
the class Main method test.
public static IntSummaryStatistics test() {
IntSummaryStatistics stat = new IntSummaryStatistics();
long limit = 50;
for (int i = 0; i < 100; i++) {
if (limit-- == 0)
break;
stat.accept(i);
}
return stat;
}
use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.
the class Main method testOfArrayAsElement.
private static IntSummaryStatistics testOfArrayAsElement() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (Number[] nums : Arrays.<Number[]>asList(new Integer[] { 1, 2, 3 })) {
int num = (int) nums[0];
stat.accept(num);
}
return stat;
}
use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.
the class Main method testOfArray.
private static IntSummaryStatistics testOfArray() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (Integer i : new Integer[] /*create array*/
{ 1, 2, 3 }) {
int i1 = i;
stat.accept(i1);
}
return stat;
}
use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.
the class Main method testNested.
public static IntSummaryStatistics testNested() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (int limit = 0; limit < 20; limit++) {
long limitInner = limit;
for (String x = ""; ; x = x + limit) {
if (limitInner-- == 0)
break;
int length = x.length();
stat.accept(length);
}
}
return stat;
}
Aggregations