insertAfter method
- T element,
- bool test(
- T
Inserts the element after the test condition becomes true.
Only meaningful, if this List is sorted in some way, as this method iterates it from the first til the last.
Implementation
void insertAfter(T element, bool Function(T) test) {
if (isEmpty || !test(this[0])) {
insert(0, element);
return;
}
for (var i = length - 1; i > -1; --i) {
if (test(this[i])) {
insert(i + 1, element);
return;
}
}
}