Does java use open addressing or chaining to implementing Hashtable?
Is one method or the other required by some specification/certification?
Does java use open addressing or chaining to implementing Hashtable?
Is one method or the other required by 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.