Best way to remove an object from an array in Processing
Posted
by cmal
on Stack Overflow
See other posts from Stack Overflow
or by cmal
Published on 2010-03-17T03:43:53Z
Indexed on
2010/03/17
3:51 UTC
Read the original article
Hit count: 340
processing
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.
© Stack Overflow or respective owner