All Packages Class Hierarchy This Package Previous Next Index
public abstract int hash()
Ideally, the hash() method should generate hash values that are fairly random. To take advantage of the performance gains of associative hashtable structures, the hash values should be evenly distributed over the size of the hashtable. When the size of the hashtable is known, the second hash() method defined next should be used.
public abstract int hash(int tableSize)
The generation of the hash value must adhere to the same three requirements detailed in the previous description; however, requirements (2) and (3) should be adhered to only for calls to the hash() method in which the tableSize argument is the same. For example, if this hash() method is repeatedly called with a tableSize of 101, the resulting hash values must all be the same. If a tableSize of 203 is then used, the resulting hash value may be different from that obtained with a tableSize of 101.
A fourth requirement is also expected when using this version of the hash() method:
If nothing else, this method should be implemented as follows:
public int hash( int tableSize )
{
// restrict hash value to 0..(tableSize-1)
return ( Math.abs( hash() ) % tableSize );
}
All Packages Class Hierarchy This Package Previous Next Index