cz.cuni.amis.utils
Class HashCode

Package class diagram package HashCode
java.lang.Object
  extended by 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; }


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

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(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 © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.