allE method
Returns true
if all elements match a condition and false
otherwise.
Applies the specified condition
function to each element in the
enumerable. The condition
function is given each element to process and
should return true
if the element matches a condition and false
if
not.
If the condition
function returns true
for all elements in the
enumerable, the allE method returns true
as well. Otherwise, if the
condition
function returns false
even once during the iteration, the
allE method will return false
as well.
The allE method will short-circuit after receiving a false
from calling
condition
and will not iterate further over the enumerable. In the worst
case, it will iterate over the entire enumerable.
Implementation
bool allE([Condition<T> condition]) {
assert(condition != null || T == bool);
if (condition == null) {
if (T == bool) {
return EnumerableReducers.AllBool(this as Enumerable<bool>);
}
throw UnexpectedStateError();
}
final iterator = this.iterator;
while (iterator.moveNext()) {
if (!condition(iterator.current)) return false;
}
return true;
}