Search in sources :

Example 6 with IntSummaryStatistics

use of java.util.IntSummaryStatistics in project java8-tutorial by winterbe.

the class Streams10 method test4.

private static void test4(List<Person> persons) {
    IntSummaryStatistics ageSummary = persons.stream().collect(Collectors.summarizingInt(p -> p.age));
    System.out.println(ageSummary);
// IntSummaryStatistics{count=4, sum=76, min=12, average=19,000000, max=23}
}
Also used : Arrays(java.util.Arrays) List(java.util.List) Map(java.util.Map) StringJoiner(java.util.StringJoiner) IntSummaryStatistics(java.util.IntSummaryStatistics) Collector(java.util.stream.Collector) Collectors(java.util.stream.Collectors) IntSummaryStatistics(java.util.IntSummaryStatistics)

Example 7 with IntSummaryStatistics

use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.

the class Main method generate.

public static IntSummaryStatistics generate() {
    IntSummaryStatistics stat = new IntSummaryStatistics();
    long limit = 33;
    OUTER: while (true) {
        Integer x = 10;
        for (int i = 0; i < x; i++) {
            if (limit-- == 0)
                break OUTER;
            stat.accept(i);
        }
    }
    return stat;
}
Also used : IntSummaryStatistics(java.util.IntSummaryStatistics)

Example 8 with IntSummaryStatistics

use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.

the class Main method generateMethodRef.

public static IntSummaryStatistics generateMethodRef() {
    IntSummaryStatistics stat = new IntSummaryStatistics();
    long limit = 33;
    OUTER: while (true) {
        Integer x = getInt();
        for (int i = 0; i < x; i++) {
            if (limit-- == 0)
                break OUTER;
            stat.accept(i);
        }
    }
    return stat;
}
Also used : IntSummaryStatistics(java.util.IntSummaryStatistics)

Example 9 with IntSummaryStatistics

use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.

the class Main method testOfSupplier.

private static IntSummaryStatistics testOfSupplier() {
    IntSummaryStatistics stat = new IntSummaryStatistics();
    for (Supplier<Integer> sup : Arrays.<Supplier<Integer>>asList(() -> 1, /*between*/
    () -> 2, () -> 3)) {
        int i = sup.get();
        stat.accept(i);
    }
    return stat;
}
Also used : Supplier(java.util.function.Supplier) IntSummaryStatistics(java.util.IntSummaryStatistics)

Example 10 with IntSummaryStatistics

use of java.util.IntSummaryStatistics in project intellij-community by JetBrains.

the class Main method testNestedRename.

public static IntSummaryStatistics testNestedRename() {
    IntSummaryStatistics stat = new IntSummaryStatistics();
    for (int x = 0; x < 20; x++) {
        if (x > 2) {
            long limit = x;
            for (String s = String.valueOf(x); ; s = s + x) {
                if (limit-- == 0)
                    break;
                int length = s.length();
                stat.accept(length);
            }
        }
    }
    return stat;
}
Also used : IntSummaryStatistics(java.util.IntSummaryStatistics)

Aggregations

IntSummaryStatistics (java.util.IntSummaryStatistics)10 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 StringJoiner (java.util.StringJoiner)1 Supplier (java.util.function.Supplier)1 Collector (java.util.stream.Collector)1 Collectors (java.util.stream.Collectors)1