How should I optimize a hash table for a given population?

Let's say I have a group of key-value pairs that I plan to store in a hash table. The population is fixed and will never change. What optimizations are available to me to make a hash table as fast as possible? What optimizations should I focus on? This suggests that I have a lot of space. There will be a reasonable number of pairs (say, no more than 100,000).

EDIT: I want to optimize the search. I don't care how long it takes to build.

+5
source share
9 answers

I would make sure your key hash has unique values. This ensures that every search is constant, and therefore as fast as possible.

100 000 , 100 000 -.

, , , int, ( 100 000) , . ( 1). , - . .

+4

, -, , , - .

, - . , , ,

+2

, . , O (1). .

. .

+1

- , , . .

, -, -.

+1

, 100 . . Java MPH package, .

+1

, - (MPH). Wikipedia Java, .

+1

int hashCode class. , , .

0

, 100K, , . . , , , 23 , , 365 .

, , 100K?

, - , , n- . , , 26 , .

26 . , f f , . . o. , o. ( , !). , , , , .

, . , , 4- . , , , . , foo, , , , foo.

, Google , .

0

, . ( .) , , -. , .. - , , .

, Java - : hashCode . -, -.

, , -, . hashCode, , , - . , , 100 , hashCode 1, 1001, 2001, 3001, 4001, 5001,... 99001. - 100 000 , . . 1000 , . .

, -. . , - . , . , , - , : . , , , "1".

, , . , ?

0

All Articles