/** * Returns a {@code Collector} accepting elements of type {@code T} that * counts the number of input elements and returns result as {@code Integer} * . If no elements are present, the result is 0. * * @param <T> the type of the input elements * @return a {@code Collector} that counts the input elements * @since 0.3.3 * @see Collectors#counting() */ public static <T> Collector<T, ?, Integer> countingInt() { return PartialCollector.intSum().asRef((acc, t) -> acc[0]++); }
/** * Returns an {@code LongCollector} that counts the number of input elements * and returns the result as {@code Integer}. If no elements are present, * the result is 0. * * @return an {@code LongCollector} that counts the input elements */ static LongCollector<?, Integer> countingInt() { return PartialCollector.intSum().asLong((box, i) -> box[0]++); }
/** * Returns an {@code IntCollector} that produces the sum of the input * elements. If no elements are present, the result is 0. * * @return an {@code IntCollector} that produces the sum of the input * elements */ static IntCollector<?, Integer> summing() { return PartialCollector.intSum().asInt((box, i) -> box[0] += i); }
/** * Returns an {@code DoubleCollector} that counts the number of input * elements and returns the result as {@code Integer}. If no elements are * present, the result is 0. * * @return an {@code DoubleCollector} that counts the input elements */ static DoubleCollector<?, Integer> countingInt() { return PartialCollector.intSum().asDouble((box, i) -> box[0]++); }
/** * Returns an {@code IntCollector} that counts the number of input elements * and returns the result as {@code Integer}. If no elements are present, * the result is 0. * * @return an {@code IntCollector} that counts the input elements */ static IntCollector<?, Integer> countingInt() { return PartialCollector.intSum().asInt((box, i) -> box[0]++); }