Is there really no method that determines the number of elements that satisfy a Predicate in an Iterable? Was I right to do this:
return Lists.newArrayList(Iterables.filter(iterable, predicate)).size()
If so, what is the reason that there is no method
Iterable.frequency(Iterable<T>, Predicate<T>)
Cheers
This may be easier:
return Iterables.size(Iterables.filter(iterable, predicate));
It avoids the allocation of all that array memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With