I am writing an N-body simulation in C++ that has to be able to deal with large N ($N \le 10^6$).
Everything has been going well so far, but now that I have started to code in collisions between bodies (which can result in mergers - which means that one body is added to the system and two are removed) I cannot help but wonder whether there is a more suitable data structure than the std::vector (which I have been using so far).
Given that each body in the system has a unique ID, I have thought of storing all bodies in an std::map (to allow fast lookup by ID), but, at the same time, I have to repeatedly iterate over all bodies (in direct integration methods) and consider each pairwise interaction ($n_{interactions}=\frac{N(N-1)}{2}$), for which (I believe) the std::vector is faster than the std::map.
What would be the best data structure for this, given that I have to iterate repeatedly over all bodies, but also have to be able to add and remove bodies?