Why doesn't Java's hashCode support universal hashing?

前端 未结 2 1025
[愿得一人]
[愿得一人] 2021-02-02 12:19

Some hash table schemes, such as cuckoo hashing or dynamic perfect hashing, rely on the existence of universal hash functions and the ability to take a collection of data exhibi

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 12:58

    I think the normal hashCode method was created without the "malicious inputs" case in mind. Also, as written by larsmann, its contract is much more easier to understand and implement than a universal hash function would be.

    Here an idea about what to do:

    • Use a map implementation relying on external hash-functions (like the HashableEquivalenceRelation I presented some hours ago here)
    • then use a universal family of such implementations (or an implementation which allows changing the parameter to switch to another member of the family).

提交回复
热议问题