mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-06-16 16:44:50 +02:00
Add CollectionUtils.count(Iterator<?>)
This commit is contained in:
parent
3cef89fc46
commit
50a8a5b7d7
|
@ -107,6 +107,15 @@ public final class CollectionUtils {
|
||||||
return reducer.getResult();
|
return reducer.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int count(Iterator<?> iterator) {
|
||||||
|
int num = 0;
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
iterator.next();
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface Filter<T> {
|
interface Filter<T> {
|
||||||
boolean accept(T t);
|
boolean accept(T t);
|
||||||
|
|
Loading…
Reference in a new issue