|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mhhe.clrs2e.MultiplicationMethod
Implements the multiplication method of hashing on pages 231-232 of Introduction to Algorithms, Second edition.
Field Summary | |
private long |
bitMask
If the table size is a power of 2, the bit mask used. |
private boolean |
isPowerOf2
true if the table size is a power of 2,
false otherwise. |
private int |
shiftAmount
If the table size is a power of 2, the shift amount used. |
private int |
tableSize
The size of the hash table being used. |
Constructor Summary | |
MultiplicationMethod(int size)
Creates a hash function that uses the multiplication method. |
Method Summary | |
int |
hash(java.lang.Object o)
Returns the hash value of an object, based on its Java hashCode value and the multiplication method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int tableSize
private boolean isPowerOf2
true
if the table size is a power of 2,
false
otherwise.
private int shiftAmount
private long bitMask
Constructor Detail |
public MultiplicationMethod(int size)
size
- The size of the hash table.Method Detail |
public int hash(java.lang.Object o)
hashCode
value and the multiplication method.
o
- The object being hashed. If the object implements
DynamicSetElement
, the hash value is of its key.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |