I believe it is somewhat common to filter a stream and count the number of elements, for example to count the number of even numbers in a range u would write:
long evenCount = IntStreamEx.range(n).filter(x -> x % 2 == 0).count();
However a count method that takes in a Predicate and only counts the element if it matches the predicate would be more convenient imo.
Example:
long evenCount = IntStreamEx.range(n).count(x -> x % 2 == 0);
I believe it is somewhat common to filter a stream and count the number of elements, for example to count the number of even numbers in a range u would write:
long evenCount = IntStreamEx.range(n).filter(x -> x % 2 == 0).count();
However a count method that takes in a Predicate and only counts the element if it matches the predicate would be more convenient imo. Example:long evenCount = IntStreamEx.range(n).count(x -> x % 2 == 0);
Alternatively the method could be called
countIf