removeWhere method

  1. @override
void removeWhere(
  1. bool test(
    1. T element
    )
)
override

Removes all objects from this slice and the underlying list that satisfy test. An object o satisfies test if test(o) is true. The slice's range shrinks by the number of elements removed. Note, the ranges of other slices on the underlying list will not change, therefore use with care as this may shift the underlying data in other slices.

Implementation

@override
void removeWhere(bool Function(T element) test) {
  int index = 0;
  int numRemoved = 0;
  _list.removeWhere((element) {
    if (index < _start || index >= _end) {
      index++;
      return false;
    }
    index++;
    if (test(element)) {
      numRemoved++;
      return true;
    }
    return false;
  });
  _end -= numRemoved;
}