Archived

This topic is now archived and is closed to further replies.

hash_map suitable ?

This topic is 5382 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 need to create a string->string association in my program where the first string (the key) is small (few characters), but the second string (the element) can be fairly large (several kilobytes). Is a hash_map suitable for a situation like this? Or could it be a problem for the hash function or something that the data is so big? or does the size of the data not really affect the access or the hashing?

Share this post


Link to post
Share on other sites
Size of the data doesn't matter. hash_map sounds like a proper choice for you. But keep in mind that when adding stuff to the hash_map or when hash_map does resizing, there'll be lots of copying of the data. I'd suggest you dynamically allocate the data with new and store it to the map as a pointer.

[edited by - civguy on March 23, 2003 3:46:12 PM]

Share this post


Link to post
Share on other sites
Ah, thanks.

Thats ok, since I will not be adding or removing from it frequently, and even when I am it will not be time critical. It will just be getting access frequently, and that access has to be fast.

Share this post


Link to post
Share on other sites