countE method
Returns the number of elements in the enumerable.
Iterates over the entire enumerable and returns the number of elements that were iterated over.
Optionally, a condition
can be specified. If so, the total count
will be the number of elements for which the condition
function
returned true
.
The countE function will iterate over every element in the enumerable.
Implementation
int countE([Condition<T> condition]) {
final iterator = this.iterator;
int count = 0;
if (condition == null) {
while (iterator.moveNext()) {
count++;
}
} else {
while (iterator.moveNext()) {
if (condition(iterator.current)) count++;
}
}
return count;
}