addAll method

ISet<T> addAll(
  1. Iterable<T>? items
)

Returns a new set containing the current set plus all the given items.

Implementation

ISet<T> addAll(Iterable<T>? items) {
  ISet<T> result;
  result = config.sort
      ? ISet._unsafe(SFlat(_s.followedBy(items!), config: config), config: config)
      : ISet<T>._unsafe(_s.addAll(items!), config: config);

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

  return result;
}