- All Known Subinterfaces:
com.dynatrace.hash4j.hashing.HashStream,HashStream128,HashStream32,HashStream64
-
Method Summary
Modifier and TypeMethodDescription<T> HashSinkput(T obj, HashFunnel<T> funnel) Adds an object to the hash computation using the given funnel.putBoolean(boolean v) Adds abooleanvalue to the hash computation.putBooleanArray(boolean[] x) Adds abooleanarray to the hash computation.putBooleans(boolean[] x) Adds all elements of abooleanarray to the hash computation.putBooleans(boolean[] x, int off, int len) Addslenelements of the givenbooleanarray to the hash computation.putByte(byte v) Adds abytevalue to the hash computation.putByteArray(byte[] x) Adds abytearray to the hash computation.putBytes(byte[] x) Adds all elements of abytearray to the hash computation.putBytes(byte[] x, int off, int len) Addslenelements of the givenbytearray to the hash computation.<T> HashSinkputBytes(T input, long off, long len, ByteAccess<T> access) Adds a sequence of bytes to the hash computation.putChar(char v) Adds acharvalue to the hash computation using little-endian byte order.putCharArray(char[] x) Adds achararray to the hash computation.putChars(char[] x) Adds all elements of achararray to the hash computation.putChars(char[] x, int off, int len) Addslenelements of the givenchararray to the hash computation.Adds chars to the hash computation.putDouble(double v) Adds adoublevalue to the hash computation using little-endian byte order.putDoubleArray(double[] x) Adds adoublearray to the hash computation.putDoubles(double[] x) Adds all elements of adoublearray to the hash computation.putDoubles(double[] x, int off, int len) Addslenelements of the givendoublearray to the hash computation.putFloat(float v) Adds afloatvalue to the hash computation using little-endian byte order.putFloatArray(float[] x) Adds afloatarray to the hash computation.putFloats(float[] x) Adds all elements of afloatarray to the hash computation.putFloats(float[] x, int off, int len) Addslenelements of the givenfloatarray to the hash computation.putInt(int v) Adds anintvalue to the hash computation using little-endian byte order.putIntArray(int[] x) Adds anintarray to the hash computation.putInts(int[] x) Adds all elements of anintarray to the hash computation.putInts(int[] x, int off, int len) Addslenelements of the givenintarray to the hash computation.putLong(long v) Adds alonglongvalue to the hash computation using little-endian byte order.putLongArray(long[] x) Adds alongarray to the hash computation.putLongs(long[] x) Adds all elements of alongarray to the hash computation.putLongs(long[] x, int off, int len) Addslenelements of the givenlongarray to the hash computation.<T> HashSinkputNullable(T obj, HashFunnel<T> funnel) Adds a nullable object to the hash computation using the given funnel.<T> HashSinkputOptional(Optional<T> obj, HashFunnel<? super T> funnel) Adds an optional object to the hash computation using the given funnel.Adds anOptionalDoubleto the hash computation.Adds anOptionalIntto the hash computation.Adds anOptionalLongto the hash computation.<T> HashSinkputOrderedIterable(Iterable<T> data, HashFunnel<? super T> funnel) Adds an orderedIterable(e.g.putShort(short v) Adds ashortvalue to the hash computation using little-endian byte order.putShortArray(short[] x) Adds ashortarray to the hash computation.putShorts(short[] x) Adds all elements of ashortarray to the hash computation.putShorts(short[] x, int off, int len) Addslenelements of the givenshortarray to the hash computation.Adds a string to the hash computation.<T> HashSinkputUnorderedIterable(Iterable<T> data, HashFunnel<? super T> funnel, Hasher64 hasher) Adds an unorderedIterable(e.g.<T> HashSinkputUnorderedIterable(Iterable<T> data, HashFunnel<? super T> funnel, HashStream64 hashStream) Adds an unorderedIterable(e.g.<T> HashSinkputUnorderedIterable(Iterable<T> data, ToLongFunction<? super T> elementHashFunction) Adds an unorderedIterable(e.g.Adds aUUIDto the hash computation.
-
Method Details
-
putByte
Adds abytevalue to the hash computation.- Parameters:
v- the value- Returns:
- this
-
putBytes
Adds all elements of abytearray to the hash computation.Unlike
putByteArray(byte[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putBytes(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putBytes
Addslenelements of the givenbytearray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putByte(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putBytes
Adds a sequence of bytes to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putByte(access.getByte(input, off + i));- Type Parameters:
T- the type of the input- Parameters:
input- the inputoff- the offsetlen- the lengthaccess- a strategy to access the bytes of the input- Returns:
- this
-
putByteArray
Adds abytearray to the hash computation.This method includes the length information. In this way,
hashSink.putByteArray(new byte[]{1, 2}).putByteArray(new byte[]{3})and
hashSink.putByteArray(new byte[]{1}).putByteArray(new byte[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putBytes(x).putInt(x.length);- Parameters:
x- the boolean array- Returns:
- this
-
putBoolean
Adds abooleanvalue to the hash computation.Equivalent to
putByte(v ? 1 : 0);- Parameters:
v- the value- Returns:
- this
-
putBooleans
Adds all elements of abooleanarray to the hash computation.Unlike
putBooleanArray(boolean[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putBooleans(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putBooleans
Addslenelements of the givenbooleanarray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putBoolean(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putBooleanArray
Adds abooleanarray to the hash computation.This method includes the length information. In this way,
hashSink.putBooleanArray(new boolean[]{true, false}).putBooleanArray(new boolean[]{true})and
hashSink.putBooleanArray(new boolean[]{true}).putBooleanArray(new boolean[]{false, true})will be different contributions to the hash value computation.
Equivalent to
putBooleans(x).putInt(x.length);- Parameters:
x- the boolean array- Returns:
- this
-
putShort
Adds ashortvalue to the hash computation using little-endian byte order.- Parameters:
v- the value- Returns:
- this
-
putShorts
Adds all elements of ashortarray to the hash computation.Unlike
putShortArray(short[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putShorts(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putShorts
Addslenelements of the givenshortarray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putShort(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putShortArray
Adds ashortarray to the hash computation.This method includes the length information. In this way,
hashSink.putShortArray(new short[]{1, 2}).putShortArray(new short[]{3})and
hashSink.putShortArray(new short[]{1}).putShortArray(new short[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putShorts(x).putInt(x.length);- Parameters:
x- the short array- Returns:
- this
-
putChar
Adds acharvalue to the hash computation using little-endian byte order.- Parameters:
v- the value- Returns:
- this
-
putChars
Adds all elements of achararray to the hash computation.Unlike
putCharArray(char[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putChars(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putChars
Addslenelements of the givenchararray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putChar(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putChars
Adds chars to the hash computation.This method does not include the length information. In this way,
hashSink.putChars("AB").putChars("C")and
hashSink.putChars("A").putChars("BC")will be equivalent contributions to the hash value computation.
Equivalent to
for (int i = 0; i < s.length(); ++i) putChar(s.charAt(i));- Parameters:
c- a char sequence- Returns:
- this
-
putCharArray
Adds achararray to the hash computation.This method includes the length information. In this way,
hashSink.putCharArray(new char[]{'A', 'B'}).putCharArray(new char[]{'C'})and
hashSink.putCharArray(new char[]{'A'}).putCharArray(new char[]{'B', 'C'})will be different contributions to the hash value computation.
Equivalent to
putChars(x).putInt(x.length);- Parameters:
x- the char array- Returns:
- this
-
putString
Adds a string to the hash computation.This method includes the length information. In this way,
hashSink.putString("AB").putString("C")and
hashSink.putString("A").putString("BC")will be different contributions to the hash value computation.
Equivalent to
putChars(s).putInt(s.length());- Parameters:
s- the string- Returns:
- this
-
putInt
Adds anintvalue to the hash computation using little-endian byte order.- Parameters:
v- the value- Returns:
- this
-
putInts
Adds all elements of anintarray to the hash computation.Unlike
putIntArray(int[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putInts(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putInts
Addslenelements of the givenintarray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putInt(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putIntArray
Adds anintarray to the hash computation.This method includes the length information. In this way,
hashSink.putIntArray(new int[]{1, 2}).putIntArray(new int[]{3})and
hashSink.putIntArray(new int[]{1}).putIntArray(new int[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putInts(x).putInt(x.length);- Parameters:
x- the int array- Returns:
- this
-
putLong
Adds alonglongvalue to the hash computation using little-endian byte order.- Parameters:
v- the value- Returns:
- this
-
putLongs
Adds all elements of alongarray to the hash computation.Unlike
putLongArray(long[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putLongs(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putLongs
Addslenelements of the givenlongarray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putLong(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putLongArray
Adds alongarray to the hash computation.This method includes the length information. In this way,
hashSink.putLongArray(new long[]{1, 2}).putLongArray(new long[]{3})and
hashSink.putLongArray(new long[]{1}).putLongArray(new long[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putLongs(x).putInt(x.length);- Parameters:
x- the int array- Returns:
- this
-
putFloat
Adds afloatvalue to the hash computation using little-endian byte order.Equivalent to
putInt(Float.floatToRawIntBits(v));- Parameters:
v- the value- Returns:
- this
-
putFloats
Adds all elements of afloatarray to the hash computation.Unlike
putFloatArray(float[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putFloats(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putFloats
Addslenelements of the givenfloatarray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putFloat(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putFloatArray
Adds afloatarray to the hash computation.This method includes the length information. In this way,
hashSink.putFloatArray(new float[]{1, 2}).putFloatArray(new float[]{3})and
hashSink.putFloatArray(new float[]{1}).putFloatArray(new float[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putFloats(x).putInt(x.length);- Parameters:
x- the float array- Returns:
- this
-
putDouble
Adds adoublevalue to the hash computation using little-endian byte order.Equivalent to
putLong(Double.doubleToRawLongBits(v));- Parameters:
v- the value- Returns:
- this
-
putDoubles
Adds all elements of adoublearray to the hash computation.Unlike
putDoubleArray(double[])this method does not add the length of the array.If the array has variable length, and it is just one of many variable-length fields of the object for which a hash value is calculated, it is highly recommended to also incorporate the length of the array to improve the hash quality and decrease the chance of hash collisions.
Equivalent to
putDoubles(x, 0, x.length);- Parameters:
x- the array- Returns:
- this
-
putDoubles
Addslenelements of the givendoublearray to the hash computation.Equivalent to
for (int i = 0; i < len; i++) putDouble(x[off + i]);- Parameters:
x- the arrayoff- the start offset in the arraylen- the number of elements- Returns:
- this
-
putDoubleArray
Adds adoublearray to the hash computation.This method includes the length information. In this way,
hashSink.putDoubleArray(new double[]{1, 2}).putDoubleArray(new double[]{3})and
hashSink.putDoubleArray(new double[]{1}).putDoubleArray(new double[]{2, 3})will be different contributions to the hash value computation.
Equivalent to
putDoubles(x).putInt(x.length);- Parameters:
x- the double array- Returns:
- this
-
putUUID
Adds aUUIDto the hash computation.Equivalent to
putLong(uuid.getLeastSignificantBits()).putLong(uuid.getMostSignificantBits());- Parameters:
uuid- the UUID- Returns:
- this
-
put
Adds an object to the hash computation using the given funnel.- Type Parameters:
T- the type- Parameters:
obj- the objectfunnel- the funnel- Returns:
- this
-
putNullable
Adds a nullable object to the hash computation using the given funnel.- Type Parameters:
T- the type- Parameters:
obj- the nullable objectfunnel- the funnel- Returns:
- this
-
putOrderedIterable
- Type Parameters:
T- the element type- Parameters:
data- the iterablefunnel- the funnel- Returns:
- this
-
putUnorderedIterable
- Type Parameters:
T- the element type- Parameters:
data- the iterableelementHashFunction- 64-bit hash function used for individual elements- Returns:
- this
- Throws:
OutOfMemoryError- if the allocation of a long array, that is able to keep a 64-bit hash for each element in the Iterable, fails
-
putUnorderedIterable
<T> HashSink putUnorderedIterable(Iterable<T> data, HashFunnel<? super T> funnel, HashStream64 hashStream) - Type Parameters:
T- the element type- Parameters:
data- the iterablefunnel- the funnelhashStream- 64-bit hash stream used for individual elements, must be a different instance than thisHashSink- Returns:
- this
- Throws:
OutOfMemoryError- if the allocation of a long array, that is able to keep a 64-bit hash for each element in the Iterable, failsIllegalArgumentException- if the hash stream is equal to thisHashSink
-
putUnorderedIterable
- Type Parameters:
T- the element type- Parameters:
data- the iterablefunnel- the funnelhasher- a 64-bit hasher- Returns:
- this
- Throws:
OutOfMemoryError- if the allocation of a long array, that is able to keep a 64-bit hash for each element in the Iterable, fails
-
putOptional
Adds an optional object to the hash computation using the given funnel.- Type Parameters:
T- the type- Parameters:
obj- the optional objectfunnel- the funnel- Returns:
- this
-
putOptionalInt
Adds anOptionalIntto the hash computation.- Parameters:
v- the optional value- Returns:
- this
-
putOptionalLong
Adds anOptionalLongto the hash computation.- Parameters:
v- the optional value- Returns:
- this
-
putOptionalDouble
Adds anOptionalDoubleto the hash computation.- Parameters:
v- the optional value- Returns:
- this
-