• Advertisement
Sign in to follow this  

STL-Container:Fast insert/isMember

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