Package org.teiid.core.util
Class HashCodeUtil
- java.lang.Object
-
- org.teiid.core.util.HashCodeUtil
-
public final class HashCodeUtil extends Object
This class provides utility functions for generating good hash codes. Hash codes generated with these methods should have a reasonably good distribution when placed in a hash structure such as Hashtable, HashSet, or HashMap.
General usage is something like:
public int hashCode() { int hc = 0; // or = super.hashCode(); hc = HashCodeUtil.hashCode(hc, intField); hc = HashCodeUtil.hashCode(hc, objectField); // etc, etc return hc; }
-
-
Constructor Summary
Constructors Constructor Description HashCodeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
expHashCode(int previous, Object[] x)
Compute a hash code on a large array by walking the list and combining the hash code at every exponential index: 1, 2, 4, 8, ...static int
expHashCode(int previous, Collection<?> x)
Compute a hash code on a large collection by walking the list and combining the hash code at every exponential index: 1, 2, 4, 8, ...static int
expHashCode(CharSequence x)
static int
expHashCode(CharSequence x, boolean caseSensitive)
static int
hashCode(int previous, boolean x)
static int
hashCode(int previous, double x)
static int
hashCode(int previous, float x)
static int
hashCode(int previous, int x)
static int
hashCode(int previous, long x)
static int
hashCode(int previous, Object... x)
-
-
-
Method Detail
-
hashCode
public static final int hashCode(int previous, boolean x)
-
hashCode
public static final int hashCode(int previous, int x)
-
hashCode
public static final int hashCode(int previous, long x)
-
hashCode
public static final int hashCode(int previous, float x)
-
hashCode
public static final int hashCode(int previous, double x)
-
hashCode
public static final int hashCode(int previous, Object... x)
-
expHashCode
public static final int expHashCode(int previous, Object[] x)
Compute a hash code on a large array by walking the list and combining the hash code at every exponential index: 1, 2, 4, 8, ... This has been shown to give a good hash for good time complexity.
-
expHashCode
public static final int expHashCode(int previous, Collection<?> x)
Compute a hash code on a large collection by walking the list and combining the hash code at every exponential index: 1, 2, 4, 8, ... This has been shown to give a good hash for good time complexity.
-
expHashCode
public static final int expHashCode(CharSequence x)
-
expHashCode
public static final int expHashCode(CharSequence x, boolean caseSensitive)
-
-