Add CollectionUtils.count(Iterator<?>)
This commit is contained in:
parent
3cef89fc46
commit
50a8a5b7d7
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue