for (int i = list.length - 1; i >= 0; --i) {
[...]
// at the very end...
if (list[i].someCondition()) {
list.removeAt(i);
}
}
You can remove elements if you iterate over the list in reverse and if you do the deletion at the very end of the loop's body. This way it doesn't matter if the elements, which follow the element you just removed, are shifted by one.
If the order doesn't need to be maintained, you can also do a somewhat cheaper swap/delete.
void unorderedDelete(List array, int index) {
var temp = array.removeLast();
if (index < array.length) {
array[index] = temp;
}
}
[...]
for (int i = list.length - 1; i >= 0; --i) {
[...]
// at the very end...
if (list[i].someCondition()) {
unorderedDelete(list, i);
}
}