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

前端 未结 2 1027
[愿得一人]
[愿得一人] 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:33

    Simplicity. Java allows class designers to provide their own hashCode, which as you mention is good enough for "ordinary" hash tables, and can be hard enough to understand.

    Besides, when the Java Collections API was designed, having generic hash tables in the standard library was bold enough a move already. C has never had them. C++ had them in the STL as hash_set and hash_map, but those didn't make it into the standard. Only now, in C++0x, are hash tables being considered for standardization again.

提交回复
热议问题