cz.cuni.amis.utils
Class HashCode
java.lang.Object
cz.cuni.amis.utils.HashCode
public final class HashCode
- extends 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;
}
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HashCode
public HashCode()
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(Object o)
add
public HashCode add(boolean b)
add
public HashCode add(byte b)
add
public HashCode add(char c)
add
public HashCode add(short s)
add
public HashCode add(int i)
add
public HashCode add(long l)
add
public HashCode add(float f)
add
public HashCode add(double d)
add
public HashCode add(Object o)
getHash
public int getHash()
Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.