goldman.collection.set
Class DirectAddressing.DirectAddressingHasher<E>
java.lang.Object
goldman.collection.set.DirectAddressing.DirectAddressingHasher<E>
- All Implemented Interfaces:
- Hasher<E>
- Enclosing class:
- DirectAddressing<E>
public static class DirectAddressing.DirectAddressingHasher<E>
- extends Object
- implements Hasher<E>
The direct addressing hasher allocates slot 0 for the null element
and adds one to each of the naturally computed hash codes for the elements.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DirectAddressing.DirectAddressingHasher
public DirectAddressing.DirectAddressingHasher()
getHashCode
public int getHashCode(E element)
- Specified by:
getHashCode
in interface Hasher<E>
- Parameters:
element
- the element for which the hash code should be computed
- Returns:
- the hash code for the given element, which may not necessarily be
related to the
element.hashCode
getTableSize
public int getTableSize(int capacity,
double load)
- Specified by:
getTableSize
in interface Hasher<E>
- Parameters:
capacity
- the desired capacity of the collectionload
- the desired load factor of the table
- Returns:
- the proper table size in accordance with the hashing algorithm and
the way hash codes are computed