writeIterable<T> static method
Write the elements of an iterable into a list.
This is a utility function that can be used to implement methods like setAll.
The elements of source
are written into target
from position at
.
The source
must not contain more elements after writing the last
position of target
.
If the source is a list, the copyRange function is likely to be more efficient.
Implementation
static void writeIterable<T>(List<T> target, int at, Iterable<T> source) {
RangeError.checkValueInInterval(at, 0, target.length, "at");
int index = at;
int targetLength = target.length;
for (var element in source) {
if (index == targetLength) {
throw IndexError.withLength(index, targetLength, indexable: target);
}
target[index] = element;
index++;
}
}