Best way to remove an object from an array in Processing
- by cmal
I really wish Processing had push and pop methods for working with Arrays, but since it does not I'm left trying to figure out the best way to remove an object at a specific position in an array. I'm sure this is as basic as it gets for many people, but I could use some help with it, and I haven't been able to figure much out by browsing the Processing reference.
I don't think it matters, but for your reference here is the code I used to add the objects initially:
Flower[] flowers = new Flower[0];
for (int i=0; i < 20; i++)
{
Flower fl = new Flower();
flowers = (Flower[]) expand(flowers, flowers.length + 1);
flowers[flowers.length - 1] = fl;
}
For the sake of this question, let's assume I want to remove an object from position 15. Thanks, guys.