How to store an array of instances
<p>I'm coding in Java, but most languages would do just fine.</p>

<p>Right now, I have an implementation like this:</p>

<p>I have an array that stores objects from a class.  The array's length is 10,000.</p>

<p>This is for a little project I working on.  Essentially, over time, any place in the array can be unused or have an object in it.  Objects can be created or destroyed at any moment.</p>

<p>What I was trying to figure out was the best way to store and recall them to minimize time for two steps:</p>

<ol>
<li><p>Creating an object.  Cycling through the array until you find an open slot can be slow when lots of instances are near the front.</p></li>
<li><p>Drawing an object.  I have to cycle through the array constantly, and, based on the existence of an instance, retrieve and display information regarding it.</p></li>
</ol>

<p>My current system uses a list of the Objects, as well as a list of Booleans.  When creating an object, I just cycle through till the first empty place in the array, then fill it, and to draw, I just go over the whole thing.</p>

<p>Granted, it isn't slow enough to make the project impossible, but I'd still like to know the most efficient method.</p>
