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;
}