I am creating a game where i have small “particles”. Their number is changing very frequently (every few seconds) and i’m wondering what is the best way to store them. Is std::vector or std::deque better for this?
Is it okay to reserve space (in that container) that will never get used (I have upper limit)?
Instead of removing a particle you can just replace it with the other one in a vector if order does not matter (and I think it does not)
when you remove a particle at index
i– just fill the empty space with the last one:You can make it even faster if using vector of pointers.