BRUtil - Making Java a Kinder, Gentler, Place to be.

brutil
Class SimpleModHashFunction

java.lang.Object
  |
  +--brutil.SimpleModHashFunction
All Implemented Interfaces:
HashFunction

public class SimpleModHashFunction
extends java.lang.Object
implements HashFunction

This class is a simple HashFunction for use with a RealtimeHashLite. Given a number of subtables and a number of buckets per table, SimpleModHashFunction returns a HashCoord (TableIndex, BucketIndex) by calculating (key % subtable number, key % number of buckets).

See Also:
HashFunction, HashStatsListener, POD, HashMap

Constructor Summary
SimpleModHashFunction(int numTables, int bucketsPerTable)
          Sole constructor.
 
Method Summary
 HashCoord hash(java.lang.Object key)
          Hashes a key for use in a RealtimeHashLite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleModHashFunction

public SimpleModHashFunction(int numTables,
                             int bucketsPerTable)
Sole constructor. Creates a SimpleModHashFunction.
Parameters:
numTables - the number of subtables in the HashMap.
tableSize - the number of buckets in the HashMap.
Method Detail

hash

public HashCoord hash(java.lang.Object key)
Hashes a key for use in a RealtimeHashLite.
Specified by:
hash in interface HashFunction
Parameters:
key - the key to hash.
Returns:
a HashCoord


BRUtil - Making Java a Kinder, Gentler, Place to be.