Jump to content
  • Advertisement
Sign in to follow this  
FirstStrike

STL-Container:Fast insert/isMember

This topic is 5013 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

Hi! In my program I want to keep track about the fields of the gamemap I have already updated this turn. For this I want to store pointers to each field in an STL container. If the pointer to a field x is not already in the container I do a default update, otherwise I perform a vector addition. Which container would you recommend (insert and isMember are needed)? It sounds like a set, but you never know... Thx!

Share this post


Link to post
Share on other sites
Advertisement
list has a slow (O(n)) membership check. I'd go with set, as both of the required operations are logarithmic. Or, if you don't need to be standard and your STL implementation includes the hash_map extension, use it, as it offers constant-time operations on average.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!