addAllStartingAt_Unsafe method

  1. @override
void addAllStartingAt_Unsafe(
  1. Iterable<T> source, [
  2. int skipItems = 0,
  3. int? nrItems
])
override

Internal implementation of addAllStartingAt, which does not do any safety checks regarding sorting. Only to be overridden in children.

Implementation

@override
// ignore: non_constant_identifier_names
void addAllStartingAt_Unsafe(Iterable<T> source,
    [int skipItems = 0, int? nrItems]) {
  // Try the fast algorithm if the data is of the correct type.
  if (runtimeType == source.runtimeType) {
    _addAllStartingAtFast_Unsafe(
        source as GpcEfficient<T>, skipItems, nrItems);
  } else {
    // No the same type -> do a slow copy.

    // For regular iterables, calling length will consume it, so we don't
    // want to do it. But for RandomAccessIterable, it's a safe operation and
    // we can use it to preset the capacity for performance reasons.
    if (source is RandomAccessIterable) {
      capacity = _elementsCount + (nrItems ?? (source.length - skipItems));
    }

    for (var element in getSubSource(source, skipItems, nrItems)) {
      add_Unsafe(element);
    }
  }
}