By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

stdext::hash_map

P: 3
Dear comunity,

my hash map is having to many collision, so I thought to increase the size of the internal index map. How can I do this?
Just increasing the functional range of the hash function?

I am using a normal stdext::hash_map with long as key and the stdext::hash function of course with long as key.

Any ideas, or is the problem to generally described?

Cheers mates,
Sebastian
Feb 22 '07 #1
Share this Question
Share on Google+
4 Replies


Ganon11
Expert 2.5K+
P: 3,652
About how many collisions are we talking about? The problem could be that the hash_map has a small range of keys to assign hash codes to, or it may be that you are using a bad hash function.
Feb 22 '07 #2

P: 3
Thanks for your answer!

About how many collisions are we talking about? The problem could be that the hash_map has a small range of keys to assign hash codes to, or it may be that you are using a bad hash function.
There are probably thousands of collisions. I am trying use tripel of short values as key...and therefore I convert the three short values to a long value. With n=300 there are n^3 = 27 Mio possible tripel, and probably 1 Mio is actually saved in the hash table. Since the running time is amazingly low I guess there are at least some thousand collisions.

As hash function I am using the stdext::hash template function, and I do not really know how large the range of the keys actually is.
I thought one of you might have used this hash_map and the hash function before and you know how to increase the range of the keys of the hash codes.
An alternative would be another hash_map / function where I could set the hash range by hand.

Sebastian
Feb 22 '07 #3

Ganon11
Expert 2.5K+
P: 3,652
As hash function I am using the stdext::hash template function, and I do not really know how large the range of the keys actually is.
I thought one of you might have used this hash_map and the hash function before and you know how to increase the range of the keys of the hash codes.
An alternative would be another hash_map / function where I could set the hash range by hand.
I wish I had, but to be honest, all I know about Hash Tables/Maps was learned in Java, and that class has a way to enlarge the size of possible keys. I'm not sure how to do this in C++.
Feb 22 '07 #4

P: 3
I wish I had, but to be honest, all I know about Hash Tables/Maps was learned in Java, and that class has a way to enlarge the size of possible keys. I'm not sure how to do this in C++.
no problem. its a taff question. nobody could answer me so far :(

thanks anyway!

still...anyone else with experience???
Feb 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.