Click here to Skip to main content
16,019,435 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Reentrancy and Thread Safety Pin
Dave Calkins22-Aug-06 18:06
Dave Calkins22-Aug-06 18:06 
QuestionActive window Pin
jpyp22-Aug-06 10:32
jpyp22-Aug-06 10:32 
AnswerRe: Active window Pin
jk chan22-Aug-06 14:16
jk chan22-Aug-06 14:16 
AnswerRe: Active window Pin
jpyp23-Aug-06 8:26
jpyp23-Aug-06 8:26 
GeneralRe: Active window Pin
jk chan23-Aug-06 14:15
jk chan23-Aug-06 14:15 
AnswerRe: Active window Pin
jpyp24-Aug-06 8:11
jpyp24-Aug-06 8:11 
GeneralRe: Active window Pin
jk chan24-Aug-06 14:25
jk chan24-Aug-06 14:25 
QuestionCMap with integer keys [modified] Pin
bob1697222-Aug-06 10:16
bob1697222-Aug-06 10:16 
I'm benchmarking some algorithm implementations and comparing different approaches and I got some results that got me thinking about CMap's hash table.

I've always used CMap with string keys and never gave the default hash function much thought outside of making sure my hash table size was roughly 20% larger than the number of objects planned to store, and that the size was a prime number as some documentation/literature recommends.

I'm playing with integer keys and my lookup times are varying enough with large samples to get me thinking that I might be doing something wrong. (I'm populating a CMap with 64 key/values and performing 50,000,000 lookups while using a performance counter. I'm comparing lookups for each of the items placed in the map)

My questions are, when using integer keys, should I expect large fluctuations in lookup time? Is my goal to set up the lookup table size to the most keys used or the highest key value? Or is it generally frowned upon to use integer keys with maps? (I understand that the hash function does this to strings anyways, but is it somehow inefficient to use integers outright?)

Thanks

-- modified at 16:57 Tuesday 22nd August, 2006

A sequential search on an array with these elements in it is getting better average times. Do I need more elements in the CMap to properly benchmark it?

I also found it is acting like there are collision in the hash table. The lookup times seem to decrease as I increment through the keys toward the center. I found something by Ivor Horton that says the default hash simply bit shifts my key 4 to the left...
AnswerRe: CMap with integer keys Pin
Jörgen Sigvardsson22-Aug-06 13:56
Jörgen Sigvardsson22-Aug-06 13:56 
GeneralRe: CMap with integer keys [modified] Pin
bob1697222-Aug-06 18:37
bob1697222-Aug-06 18:37 
GeneralRe: CMap with integer keys Pin
Blake Miller29-Sep-06 8:37
Blake Miller29-Sep-06 8:37 
GeneralRe: CMap with integer keys Pin
bob169721-Oct-06 7:56
bob169721-Oct-06 7:56 
GeneralRe: CMap with integer keys Pin
Blake Miller2-Oct-06 2:22
Blake Miller2-Oct-06 2:22 
Questionfunction hooks Pin
inebriate22-Aug-06 8:55
inebriate22-Aug-06 8:55 
AnswerRe: function hooks Pin
Jörgen Sigvardsson22-Aug-06 13:54
Jörgen Sigvardsson22-Aug-06 13:54 
AnswerRe: function hooks Pin
Dave Calkins22-Aug-06 18:15
Dave Calkins22-Aug-06 18:15 
Questionexceptions Pin
jon-8022-Aug-06 8:48
professionaljon-8022-Aug-06 8:48 
QuestionRe: exceptions Pin
David Crow22-Aug-06 8:57
David Crow22-Aug-06 8:57 
AnswerRe: exceptions Pin
jon-8022-Aug-06 9:06
professionaljon-8022-Aug-06 9:06 
GeneralRe: exceptions Pin
Zac Howland22-Aug-06 9:10
Zac Howland22-Aug-06 9:10 
GeneralRe: exceptions Pin
David Crow22-Aug-06 9:21
David Crow22-Aug-06 9:21 
GeneralRe: exceptions Pin
Zac Howland22-Aug-06 9:22
Zac Howland22-Aug-06 9:22 
QuestionRe: exceptions Pin
David Crow22-Aug-06 9:32
David Crow22-Aug-06 9:32 
AnswerRe: exceptions Pin
Zac Howland22-Aug-06 9:42
Zac Howland22-Aug-06 9:42 
GeneralRe: exceptions Pin
David Crow22-Aug-06 9:47
David Crow22-Aug-06 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.