}); } else { groupingBy = partial.asRef(accumulator);
/** * Returns a {@code Collector} which produces a boolean array containing the * results of applying the given predicate to the input elements, in * encounter order. * * @param <T> the type of the input elements * @param predicate a non-interfering, stateless predicate to apply to each * input element. The result values of this predicate are collected * to the resulting boolean array. * @return a {@code Collector} which collects the results of the predicate * function to the boolean array, in encounter order. * @since 0.3.8 */ public static <T> Collector<T, ?, boolean[]> toBooleanArray(Predicate<T> predicate) { return PartialCollector.booleanArray().asRef((box, t) -> { if (predicate.test(t)) box.a.set(box.b); box.b = StrictMath.addExact(box.b, 1); }); }
/** * 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]++); }