I'm working on an Entity-Component System, and now that I got everything up and running I decided to delve a bit into optimizations. Currently, I have a Gameobject class that stores an unordered_map with component IDs and respective component pointers. To speed things up, I want to try to allocate components on the heap in contiguous memory without copying them into a vector. With this I would be able to iterate over them simply by getting the first component then moving up from that address by the size of the component, essentially eliminating the constant searching the computer would otherwise have to go through to find the different memory addresses when iterating over their pointers.
Is there a way to do such a thing?