cz.cuni.utils
Class HashCode

java.lang.Object
  extended by cz.cuni.utils.HashCode

public final class HashCode
extends java.lang.Object

This class is meant for counting hash codes from any possible type. It declares a two heavily overloaded methods ;-). 1) hash(whatever) -> returns hash number for 'whatever' (of whatever type) 2) add(whatever) -> add number to the hashCode for 'whatever' (of whatever type) Typical usage: Usualy you will create a method private countHashCode() which you will call from within the constructors after you've initialized variables from which you want to count the hash code. It will look like this: private int getHashCode(){ HashCode hc = new HashCode(); // creating new HashCode instance hc.add(myFirstIntValue); // adding first parametr to hash code hc.add(mySecondIntValue); // second... hc.add(myFloatValue); // third... return hc.getHash(); // returning the hash } private final int hashCode; public int ConstrucotrOfMyClass(){ // initializing variables hashCode = getHashCode(); } public int hashCode(){ return hashCode; }


Field Summary
private  int hashCode
           
 
Constructor Summary
HashCode()
           
 
Method Summary
 void add(boolean b)
           
 void add(byte b)
           
 void add(double d)
           
 void add(float f)
           
 void add(char c)
           
 void add(int i)
           
 void add(long l)
           
 void add(java.lang.Object o)
           
 void add(short s)
           
private  void addNumber(int number)
           
 int getHash()
           
 int hash(boolean b)
           
 int hash(byte b)
           
 int hash(double d)
           
 int hash(float f)
           
 int hash(char c)
           
 int hash(int i)
           
 int hash(long i)
           
 int hash(java.lang.Object o)
           
 int hash(short s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hashCode

private int hashCode
Constructor Detail

HashCode

public HashCode()
Method Detail

hash

public int hash(boolean b)

hash

public int hash(byte b)

hash

public int hash(char c)

hash

public int hash(short s)

hash

public int hash(int i)

hash

public int hash(long i)

hash

public int hash(float f)

hash

public int hash(double d)

hash

public int hash(java.lang.Object o)

addNumber

private void addNumber(int number)

add

public void add(boolean b)

add

public void add(byte b)

add

public void add(char c)

add

public void add(short s)

add

public void add(int i)

add

public void add(long l)

add

public void add(float f)

add

public void add(double d)

add

public void add(java.lang.Object o)

getHash

public int getHash()