goldman.collection.set
Class SeparateChaining.DefaultSeparateChainingHasher<E>

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

public static class SeparateChaining.DefaultSeparateChainingHasher<E>
extends Object
implements Hasher<E>

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


Constructor Summary
SeparateChaining.DefaultSeparateChainingHasher()
           
 
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

SeparateChaining.DefaultSeparateChainingHasher

public SeparateChaining.DefaultSeparateChainingHasher()
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