What is a sensible prime for hashcode calculation?

后端 未结 6 776
故里飘歌
故里飘歌 2020-11-29 16:27

Eclipse 3.5 has a very nice feature to generate Java hashCode() functions. It would generate for example (slightly shortened:)

class HashTest {
    int i;
           


        
6条回答
  •  攒了一身酷
    2020-11-29 16:36

    I'd choose 7243. Large enough to avoid collissions with small numbers. Doesn't overflow to small numbers quickly.

提交回复
热议问题