goldman.collection.set
Class OpenAddressing.DefaultOpenAddressingHasher<E>

java.lang.Object
  extended by goldman.collection.set.OpenAddressing.DefaultOpenAddressingHasher<E>
All Implemented Interfaces:
Hasher<E>
Enclosing class:
OpenAddressing<E>

public static class OpenAddressing.DefaultOpenAddressingHasher<E>
extends Object
implements Hasher<E>

The default open addressing hasher provides a default hasher for open addressing that hashes null to slot 0, and uses the element's hash code for all other elements.


Constructor Summary
OpenAddressing.DefaultOpenAddressingHasher()
           
 
Method Summary
 int getHashCode(E element)
           
 int getTableSize(int capacity, double load)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenAddressing.DefaultOpenAddressingHasher

public OpenAddressing.DefaultOpenAddressingHasher()
Method Detail

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 collection
load - 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