Quote:
Originally Posted by Jared
We could figure out the size of the arraylist right now, but if we needed to change the auto mode to avoid colliding with other robots, the length of the list would change. We don't have a spare roboRIO, and our current one is in the bag, so I won't have be able to test any of my changes for a few weeks.
|
You don't need the exact size of the arraylist when you allocate, as it will be expanded even if you set an initial size. Your goal here is to reduce the number of times the underlying array is grown.
I think
this is the current source for ArrayList. Note that the size starts out at 10 and grows by size >> 1. Each time it grows, there's a fully copy of the array made. (see method grow()). In your scenario, I'd set it to an estimate of your maximum size plus a buffer (say 10%).