I have three fields, namely
I am trying to write a function in java that returns a unique hash value ( long must be a hash return value type ) for the above fields. This hash will then be used to store the database rows corresponding to the above fields in the HashSet. I am new to writing a hash function, can someone please see what I have.
public class HashCode { private long Number1; private long Number2; String Time; public HashCode(long Number1, long Number2, String Time){ this.Number1 = Number1; this.Number2 = Number2; this.Time = Time; } public long getHashCode() { long hash = 3; hash = 47 * hash + (long) (this.Number1 ^ (this.Number1 >>> 32)); hash = 47 * hash + (long) (this.Number2 ^ (this.Number2 >>> 32)); hash = 47 * hash + (this.Time != null ? this.Time.hashCode() : 0); return hash; } }
source share