addAll method

IList<T> addAll(
  1. Iterable<T> items
)

Returns a new list with all items added to the end of the current list, (thus extending the length by the length of items).

Implementation

IList<T> addAll(Iterable<T> items) {
  if (_l is L<Never>) return IListImpl.unsafe(_l.cast<T>().toList(), config: config);
  var result = IList<T>._unsafe(_l.addAll(items), config: config);

  // A list created with `addAll` has a larger counter than both its source
  // lists. This improves the order in which lists are flushed.
  // If the outer list is used, it will be flushed before the source lists.
  // If the source lists are not used directly, they will not flush
  // unnecessarily, and also may be garbage collected.
  result._counter = max(_counter, ((items is IList<T>) ? (items)._counter : 0));
  result._count();

  return result;
}