isPartitioned method

  1. @override
bool isPartitioned(
  1. bool f(
    1. T
    )
)

Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return true precede all those that return false.

Implementation

@override
bool isPartitioned(bool Function(T) f) {
  var foundFalse = false;
  for (final element in this) {
    if (f(element)) {
      if (foundFalse) {
        return false;
      }
    } else {
      foundFalse = true;
    }
  }
  return true;
}