resizeAndGenerate method

void resizeAndGenerate(
  1. int resizeBy,
  2. ListGenerator<T> generator
)

Resizes the list by resizeBy, setting the new elements with the generator if resizeBy is positive, otherwise removing elements if resizeBy is negative.

Implementation

void resizeAndGenerate(int resizeBy, ListGenerator<T> generator) {
  if (resizeBy.isNegative) {
    removeFromEnd(-resizeBy);
  } else {
    addAll(List<T>.generate(resizeBy, generator));
  }
}