Original Post
I need to make an "array" of equal size to a vector that I'm using to store ammo. I want the array to have either a 0 or 1 at each index to correspond to an inactive/active ammo object to avoid creating/destroying them as the game goes on. My first thought was to use a char vector, and I can return any value simply with at() or [], but how can I efficiently set a single value at a specific point(I plan to recycle ammo objects) without changing the rest?
First I thought of using insert() and delete() for each change, but then I realized that delete() does not exist for vectors...So then I thought that I could loop through the vector and create a temporary copy and then set the original equal to the slightly changed copy, but that seems like it would be slower than necessary. So then I thought tha I could just use 'new' to create a normal char(or bool) array with a variable at run-time, but I would rather avoid 'new' if possible without excessive trouble.
First I thought of using insert() and delete() for each change, but then I realized that delete() does not exist for vectors...So then I thought that I could loop through the vector and create a temporary copy and then set the original equal to the slightly changed copy, but that seems like it would be slower than necessary. So then I thought tha I could just use 'new' to create a normal char(or bool) array with a variable at run-time, but I would rather avoid 'new' if possible without excessive trouble.