Add CollectionUtils.count(Iterator<?>)

This commit is contained in:
Paul Schaub 2022-07-04 12:58:42 +02:00
parent 3cef89fc46
commit 50a8a5b7d7
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 9 additions and 0 deletions

View File

@ -107,6 +107,15 @@ public final class CollectionUtils {
return reducer.getResult();
}
public static int count(Iterator<?> iterator) {
int num = 0;
while (iterator.hasNext()) {
iterator.next();
num++;
}
return num;
}
@FunctionalInterface
interface Filter<T> {
boolean accept(T t);