开发者

Algorithm used in Hashtable implementation?

开发者 https://www.devze.com 2023-03-26 12:03 出处:网络
Does java use open addressing or chaining to implementing Hashtable? Is one method or the other required by 开发者_JS百科some specification/certification?If you look at the Javadoc for Hashtable, you

Does java use open addressing or chaining to implementing Hashtable?

Is one method or the other required by 开发者_JS百科some specification/certification?


If you look at the Javadoc for Hashtable, you'll notice that it doesn't specify which hash scheme it uses. This means that any compliant Java implementation could implement this object however it sees fit, as long as it obeys the complexity guarantees specified in the interface. A compliant implementation could use chaining, quadratic hashing, Robin hood hashing, dynamic perfect hashing, Cuckoo hashing, etc. as long as the guarantees specified in the interface were met.

From a client perspective, you shouldn't need to worry about this, though.


Both java.util.HashMap and java.util.Hashtable use some sort of chaining, at least in the implementation used in the Sun/Oracle JRE and the OpenJDK one.


The specification is in the Javadoc.

0

精彩评论

暂无评论...
验证码 换一张
取 消