replaceRange method
Removes the objects in the range start
inclusive to end
exclusive
and inserts the contents of replacement
in its place.
final IList<int> ilist = [1, 2, 3, 4, 5].lock;
ilist.replaceRange(1, 4, [6, 7]).join(', '); // '1, 6, 7, 5'
The provided range, given by start
and end
, must be valid.
A range from start
to end
is valid if 0 <= start <= end <= len
, where
len
is this list's length
. The range starts at start
and has length
end - start
. An empty range (with end == start
) is valid.
This method does not work on fixed-length lists, even when replacement
has the same number of elements as the replaced range. In that case use
setRange instead.
Implementation
@useCopy
IList<T> replaceRange(int start, int end, Iterable<T> replacement) {
// TODO: Still need to implement efficiently.
return IList._unsafeFromList(toList(growable: true)..replaceRange(start, end, replacement),
config: config);
}