public class HashUtil extends Object
hashCode()values in data objects. For example, to calculate the hashCode of a data object, use the methods of this class as follows:
int myIntField; Object myObject; public int hashCode() { // int hash = super.hashCode(); // use when not extending Object int hash = 0; // use when extending Object hash = HashUtil.hashCode(hash, myIntField); hash = HashUtil.hashCode(hash, myObject); return hash; }
Modifier and Type | Field and Description |
---|---|
static int |
PRIME |
Modifier and Type | Method and Description |
---|---|
static int |
hashCode(int source,
boolean x) |
static int |
hashCode(int source,
Collection<?> c) |
static int |
hashCode(int source,
double x) |
static int |
hashCode(int source,
float x) |
static int |
hashCode(int source,
int x) |
static int |
hashCode(int source,
long x) |
static int |
hashCode(int source,
Object x) |
static int |
hashCode(int source,
Object[] x) |
public static final int PRIME
public static final int hashCode(int source, boolean x)
source
- x
- public static final int hashCode(int source, int x)
source
- x
- public static final int hashCode(int source, long x)
source
- x
- public static final int hashCode(int source, float x)
source
- x
- public static final int hashCode(int source, double x)
source
- x
- public static final int hashCode(int source, Object x)
source
- x
- public static final int hashCode(int source, Collection<?> c)
source
- c
- public static final int hashCode(int source, Object[] x)
source
- x
- Copyright © 2018. All rights reserved.