public static final class CrossHash.Water
extends java.lang.Object
hash(int[])
method is almost twice as fast
as CrossHash.Hive.hash(int[])
and faster than Arrays.hashCode(int[])
; on longer arrays
CrossHash.Curlup.hash(int[])
is faster. Based on wyhash,
specifically the waterhash variant. This version passes
SMHasher for both the 32-bit output hash() methods and the 64-bit output hash64() methods (which use the slightly
tweaked wheathash variant in the waterhash Git repo, or woothash for hashing long arrays). While an earlier
version passed rurban/smhasher, it failed demerphq/smhasher (Yves' more stringent fork), so some minor tweaks
allowed the latest code to pass Yves' test. Uses 64-bit math, so it won't be as fast on GWT. Currently, the
methods that hash types other than int arrays aren't as fast as the int array hash, but they are usually faster
than the former default Hive implementation, and unlike Hive, these pass SMHasher. If you want to have a seed the
hash, so hashing the same data with a different seed produces different output, you can use CrossHash.Yolk
or
CrossHash.Curlup
, preferring Curlup unless all of your data is in small arrays (under 20 length, give or take).
mum(long, long)
, which helps take two inputs
and multiply them once, getting a more-random result after another small step. The long array code uses
wow(long, long)
(similar to mum upside-down), which mixes up its arguments with each other before
multplying. It finishes with either code similar to mum() for 32-bit output hash() methods, or a somewhat more
rigorous method for 64-bit output hash64() methods (still similar to mum).Modifier and Type | Field and Description |
---|---|
static long |
b0
Big constant 0.
|
static long |
b1
Big constant 1.
|
static long |
b2
Big constant 2.
|
static long |
b3
Big constant 3.
|
static long |
b4
Big constant 4.
|
static long |
b5
Big constant 5.
|
Constructor and Description |
---|
Water() |
Modifier and Type | Method and Description |
---|---|
static int |
hash(boolean[] data) |
static int |
hash(byte[] data) |
static int |
hash(char[] data) |
static int |
hash(char[][] data) |
static int |
hash(char[] data,
int start,
int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
|
static int |
hash(java.lang.CharSequence data) |
static int |
hash(java.lang.CharSequence[]... data) |
static int |
hash(java.lang.CharSequence[] data) |
static int |
hash(java.lang.CharSequence data,
int start,
int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
|
static int |
hash(double[] data) |
static int |
hash(float[] data) |
static int |
hash(int[] data) |
static int |
hash(int[][] data) |
static int |
hash(int[] data,
int length) |
static int |
hash(java.lang.Iterable<? extends java.lang.CharSequence> data) |
static int |
hash(java.util.List<? extends java.lang.CharSequence> data) |
static int |
hash(long[] data) |
static int |
hash(long[][] data) |
static int |
hash(java.lang.Object data) |
static int |
hash(java.lang.Object[] data) |
static int |
hash(short[] data) |
static long |
hash64(boolean[] data) |
static long |
hash64(byte[] data) |
static long |
hash64(char[] data) |
static long |
hash64(char[][] data) |
static long |
hash64(char[] data,
int start,
int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
|
static long |
hash64(java.lang.CharSequence data) |
static long |
hash64(java.lang.CharSequence[]... data) |
static long |
hash64(java.lang.CharSequence[] data) |
static long |
hash64(java.lang.CharSequence data,
int start,
int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).
|
static long |
hash64(double[] data) |
static long |
hash64(float[] data) |
static long |
hash64(int[] data) |
static long |
hash64(int[][] data) |
static long |
hash64(int[] data,
int length) |
static long |
hash64(java.lang.Iterable<? extends java.lang.CharSequence> data) |
static long |
hash64(java.util.List<? extends java.lang.CharSequence> data) |
static long |
hash64(long[] data) |
static long |
hash64(long[][] data) |
static long |
hash64(java.lang.Object data) |
static long |
hash64(java.lang.Object[] data) |
static long |
hash64(short[] data) |
static long |
mum(long a,
long b)
Takes two arguments that are technically longs, and should be very different, and uses them to get a result
that is technically a long and mixes the bits of the inputs.
|
static long |
wow(long a,
long b)
A slower but higher-quality variant on
mum(long, long) that can take two arbitrary longs (with any
of their 64 bits containing relevant data) instead of mum's 32-bit sections of its inputs, and outputs a
64-bit result that can have any of its bits used. |
public static final long b0
public static final long b1
public static final long b2
public static final long b3
public static final long b4
public static final long b5
public static long mum(long a, long b)
a
- a long that should probably only hold an int's worth of datab
- a long that should probably only hold an int's worth of datapublic static long wow(long a, long b)
mum(long, long)
that can take two arbitrary longs (with any
of their 64 bits containing relevant data) instead of mum's 32-bit sections of its inputs, and outputs a
64-bit result that can have any of its bits used.
a
- any longb
- any longpublic static long hash64(boolean[] data)
public static long hash64(byte[] data)
public static long hash64(short[] data)
public static long hash64(char[] data)
public static long hash64(java.lang.CharSequence data)
public static long hash64(int[] data)
public static long hash64(int[] data, int length)
public static long hash64(long[] data)
public static long hash64(float[] data)
public static long hash64(double[] data)
public static long hash64(char[] data, int start, int end)
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)public static long hash64(java.lang.CharSequence data, int start, int end)
data
- the String or other CharSequence to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)public static long hash64(char[][] data)
public static long hash64(int[][] data)
public static long hash64(long[][] data)
public static long hash64(java.lang.CharSequence[] data)
public static long hash64(java.lang.CharSequence[]... data)
public static long hash64(java.lang.Iterable<? extends java.lang.CharSequence> data)
public static long hash64(java.util.List<? extends java.lang.CharSequence> data)
public static long hash64(java.lang.Object[] data)
public static long hash64(java.lang.Object data)
public static int hash(boolean[] data)
public static int hash(byte[] data)
public static int hash(short[] data)
public static int hash(char[] data)
public static int hash(java.lang.CharSequence data)
public static int hash(int[] data)
public static int hash(int[] data, int length)
public static int hash(long[] data)
public static int hash(float[] data)
public static int hash(double[] data)
public static int hash(char[] data, int start, int end)
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)public static int hash(java.lang.CharSequence data, int start, int end)
data
- the String or other CharSequence to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)public static int hash(char[][] data)
public static int hash(int[][] data)
public static int hash(long[][] data)
public static int hash(java.lang.CharSequence[] data)
public static int hash(java.lang.CharSequence[]... data)
public static int hash(java.lang.Iterable<? extends java.lang.CharSequence> data)
public static int hash(java.util.List<? extends java.lang.CharSequence> data)
public static int hash(java.lang.Object[] data)
public static int hash(java.lang.Object data)
Copyright © Eben Howard 2012–2022. All rights reserved.