org.jjoost.util
Class Rehashers

java.lang.Object
  extended by org.jjoost.util.Rehashers

public class Rehashers
extends java.lang.Object

A collection of default implementations of Rehasher

Author:
b.elliottsmith

Constructor Summary
Rehashers()
           
 
Method Summary
static Rehasher compose(Rehasher applySecond, Rehasher applyFirst)
          Returns a Rehasher that composes the two provided Rehashers, applying the second argument to the input first, and providing the result of this to the Rehasher provided in the first argument
static Rehasher flip()
          a Rehasher that reverses the bit string of the input
static Rehasher flipEveryHalfByte()
          Return a Rehasher that considers its input as a bit string, and reverses each 4 bit substring within the input
static Rehasher identity()
          Return a Rehasher that does not modify its input
static Rehasher jdkConcurrentHashmapRehasher()
          Return a Rehasher which uses the same algorithm as java.util.concurrent.ConcurrentHashMap
static Rehasher jdkHashmapRehasher()
          Return a Rehasher which uses the same algorithm as java.util.HashMap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rehashers

public Rehashers()
Method Detail

jdkHashmapRehasher

public static Rehasher jdkHashmapRehasher()
Return a Rehasher which uses the same algorithm as java.util.HashMap

Returns:
a Rehasher which uses the same algorithm as java.util.HashMap

jdkConcurrentHashmapRehasher

public static Rehasher jdkConcurrentHashmapRehasher()
Return a Rehasher which uses the same algorithm as java.util.concurrent.ConcurrentHashMap

Returns:
a Rehasher which uses the same algorithm as java.util.concurrent.ConcurrentHashMap

identity

public static Rehasher identity()
Return a Rehasher that does not modify its input

Returns:
a Rehasher that does not modify its input

flipEveryHalfByte

public static Rehasher flipEveryHalfByte()
Return a Rehasher that considers its input as a bit string, and reverses each 4 bit substring within the input

Returns:
a Rehasher that flips each 4 bit substring within the input

flip

public static Rehasher flip()
a Rehasher that reverses the bit string of the input

Returns:
a Rehasher that reverses the bit string of the input

compose

public static Rehasher compose(Rehasher applySecond,
                               Rehasher applyFirst)
Returns a Rehasher that composes the two provided Rehashers, applying the second argument to the input first, and providing the result of this to the Rehasher provided in the first argument

Parameters:
applySecond - Rehasher to apply second
applyFirst - Rehasher to apply first
Returns:
a Rehasher that returns applySecond.rehash(applyFirst.rehash(h))