removeN method

void removeN(
  1. T item,
  2. int n
)

Remove first n occurrences of item from the list. If n is negative, remove from end of list.

Implementation

void removeN(T item, int n) {
  if (n == 0) return;
  if (n > 0) {
    for (var i = 0; i < n; i++) {
      removeFirst(item);
    }
  } else {
    for (var i = 0; i < -n; i++) {
      removeLast(item);
    }
  }
}