Sign in to follow this  
M4573R

Quick and Efficient Storage of pointers to objects

Recommended Posts

I'm wondering what is the best way of storing a long list of pointers to objects where they the items will constantly be removed from random places. An example would be game objects. I was thinking a hash table using the object's pointer as the key and a custom memory allocator to keep the data on the same page would work well, but I don't think there's a hash table container in the STL. The other option I can think of would be a standard map. Any ideas? Thanks

Share this post


Link to post
Share on other sites
what about creating a std::pair<pointer,aloc> ?
then you can choose where to put it in :) vector, list, set,... depends on what you need (easy adding elements? fast searching ? ... )

you could also use the boost::hash ;)

Share this post


Link to post
Share on other sites
It sounds like you'd want a set instead of a map. I'd give boost::unordered_set a try, possibly with one of the boost pooled allocators before you try making your own.

Share this post


Link to post
Share on other sites
I've never used boost before. I need fast deletion, addition, and iterating. So I guess that's about everything. I'll try the unordered set first. Object allocation can come later, but I didn't know boost had one. :)

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this