anyE method
Returns true
if any one element matches 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 any element in the
enumerable, the anyE method returns true
as well. Otherwise, if the
condition
function returns false
for every element, the anyE method
will return false
as well.
The anyE method will short-circuit after receiving a true
from calling
condition
and will not iterate further over the enumerable. In the worst
case, it will iterate over the entire enumerable.
Implementation
bool anyE([Condition<T> condition]) {
IncompatibleTypeError.checkValidTypeOrParam(T, [bool], condition);
if (condition == null) {
if (T == bool) {
return AnyReducers.AnyBool(this as Enumerable<bool>);
}
throw UnexpectedStateError();
}
final iterator = this.iterator;
while (iterator.moveNext()) {
if (condition(iterator.current)) return true;
}
return false;
}