isSortedByKey<U extends Comparable<U> > method
Checks if the elements of this iterator are sorted by a key. That is, for each element f(a) and its following element f(b), f(a) <= f(b) must hold. If the iterator yields exactly zero or one element, true is returned. negative if a < b zero if a == b positive if a > b
Implementation
@override
bool isSortedByKey<U extends Comparable<U>>(U Function(T) f) {
U prev;
if (moveNext()) {
prev = f(current);
} else {
return true;
}
for (final element in this) {
final val = f(element);
if (prev.compareTo(val) > 0) {
return false;
}
prev = val;
}
return true;
}