Iterator
shiffman opened this issue · comments
Need to decide whether to use Iterator in the examples or not. It needs an explicit import now. It seems to be supported by Processing.js but maybe less risk to iterate with i.
Iterator<Particle> it = particles.iterator();
while (it.hasNext()) {
Particle p = it.next();
p.run();
if (p.isDead()) {
it.remove();
}
}
vs.
for (int i = particles.size()-1; i >=0; i--) {
Particle p = particles.get(i);
p.run();
if (p.isDead()) {
particles.remove(i);
}
}
Iterators work faster, but I think that is good to understand the implications of an iteration to use an decreasing for loop