• Advertisement
Sign in to follow this  

Quick and Efficient Storage of pointers to objects

This topic is 3155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement