I know that Java has beautiful inbuilt support for the HashMaps or HashTables.
Does anybody have knowledge that what kind of hashing functions or techniques are employed by Java language?
Is it possible to tweak those functions to be able to make them more specific to one's application in order to improve performance and reducing access time?
Thanks a lot for reading!
Java allows you to override the hashCode()
method for your Classes to use a hashing algorithm that is not only well suited to your application, but to your individual types:
public class Employee {
private int id;
// Default implementation might want to use "name" for as part of hashCode
private String name;
@Override
public int hashCode() {
// We know that ID is always unique, so don't use name in calculating
// the hash code.
return id;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With