I'm implementing a simple pooling system in my box2d based game to spawn/despawn/pre-pool all objects. The objects in question are all circles that are created at a set radius. e.g. When I pre-pool I create 10 x 2m, 5 x 5m, 5 x 10m circles.
Right now i'm using a simple linked list to store pooled objects, so when I need to get an object of radius x, it might take till the end of the list to either find the body with the correct radius, or not find it at all. Which is obviously cumbersome and would only become worse as I pool more objects.
I was thinking of using a hash table, so I could use the radius as a key to hash and quickly access the proper object, but my worry is that the radius values vary greatly by value and number of objects using them. e.g. i might have 50 hash at 2m and 5 hash at 100m and this would cause a create deal of wasted space right?
I'm inexperienced in using data structures and I would like to learn more, so what type of data structure would be best to efficiently handle a system like this and why?
Thank you!