tryInsert5 method
Inserts five elements into the iterable at the specified index.
Takes the specified elements and inserts it into the iterable at the
position index
.
If index
is less than zero, an ArgumentError is thrown.
If iteration of this iterable is exausted before the position index
is reached, the given elements are not inserted and this iterable is unchanged.
Implementation
Iterable<T> tryInsert5(int index, T v1, T v2, T v3, T v4, T v5) sync* {
if (index == 0) {
yield* prepend5(v1, v2, v3, v4, v5);
return;
}
if (index < 0) {
throw ArgumentError('Parameter "index" must be greater than zero.');
}
final iterator = this.iterator;
var i = 0;
while (iterator.moveNext()) {
if (i == index) {
yield v1;
yield v2;
yield v3;
yield v4;
yield v5;
}
yield iterator.current;
i++;
}
}