Package squidpony.squidmath
Class CrossHash.Curlup
java.lang.Object
squidpony.squidmath.CrossHash.Curlup
- Enclosing class:
- CrossHash
public static final class CrossHash.Curlup extends Object
Like Yolk, this is a class for hash functors, each an object with a 64-bit long seed. It uses an odd-but-fast
SIMD-friendly technique when hashing 32-bit items or smaller, and falls back to Yolk's algorithm when hashing
long values. If you are mainly hashing int arrays, short arrays, or byte arrays, this is probably the fastest
hash here unless the arrays are small (it outperforms all of the other hashes here on int arrays when those
arrays have length 50, and probably is faster than some sooner than that). Notably, on arrays 50 or longer this
runs in very close to half the time of
This hash is much more effective with large inputs because it takes advantage of HotSpot's optimizations for code that looks like a dot product over part of an array. The general concept for this hash came from the "Unrolled" hash in one of Richard Startin's blog posts, which traces back to Peter Levart posting a related improvement on String.hashCode() in 2014. This isn't as fast as Startin's "Vectorized" hash, but this works on variable array lengths and also passes SMHasher.
The name curlup comes from an M.C. Escher painting of a creature, whose name translates to curl-up, that could walk on six legs to climb stairs, or roll at high speeds when the conditions were right.
Arrays.hashCode(int[])
. This passes SMHasher for at least 64-bit
output. Has a lot of predefined functors (192, named after 24 Greek letters and 72 Goetic demons, see
Wikipedia for the demons,
in both lower case and lower case with a trailing underscore). You probably want to use predefined
instead of wrangling demon names; you can always choose an element from predefined with a 7-bit number, and there
are 64 numbers outside that range so you can choose any of those when a functor must be different.
This hash is much more effective with large inputs because it takes advantage of HotSpot's optimizations for code that looks like a dot product over part of an array. The general concept for this hash came from the "Unrolled" hash in one of Richard Startin's blog posts, which traces back to Peter Levart posting a related improvement on String.hashCode() in 2014. This isn't as fast as Startin's "Vectorized" hash, but this works on variable array lengths and also passes SMHasher.
The name curlup comes from an M.C. Escher painting of a creature, whose name translates to curl-up, that could walk on six legs to climb stairs, or roll at high speeds when the conditions were right.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Curlup()
Curlup(long seed)
Curlup(CharSequence seed)
-
Method Summary
Modifier and Type Method Description int
hash(boolean[] data)
int
hash(byte[] data)
int
hash(char[] data)
int
hash(char[][] data)
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).int
hash(double[] data)
int
hash(float[] data)
int
hash(int[] data)
int
hash(int[][] data)
int
hash(int[] data, int length)
int
hash(long[] data)
int
hash(long[][] data)
static int
hash(long seed, boolean[] data)
static int
hash(long seed, byte[] data)
static int
hash(long seed, char[] data)
static int
hash(long seed, char[][] data)
static int
hash(long seed, 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(long seed, double[] data)
static int
hash(long seed, float[] data)
static int
hash(long seed, int[] data)
static int
hash(long seed, int[][] data)
static int
hash(long seed, int[] data, int length)
static int
hash(long seed, long[] data)
static int
hash(long seed, long[][] data)
static int
hash(long seed, short[] data)
static int
hash(long seed, CharSequence data)
static int
hash(long seed, CharSequence[] data)
static int
hash(long seed, CharSequence[]... data)
static int
hash(long seed, 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(long seed, Iterable<? extends CharSequence> data)
static int
hash(long seed, Object data)
static int
hash(long seed, Object[] data)
static int
hash(long seed, List<? extends CharSequence> data)
int
hash(short[] data)
int
hash(CharSequence data)
int
hash(CharSequence[] data)
int
hash(CharSequence[]... data)
int
hash(CharSequence data, int start, int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).int
hash(Iterable<? extends CharSequence> data)
int
hash(Object data)
int
hash(Object[] data)
int
hash(List<? extends CharSequence> data)
long
hash64(boolean[] data)
long
hash64(byte[] data)
long
hash64(char[] data)
long
hash64(char[][] data)
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).long
hash64(double[] data)
long
hash64(float[] data)
long
hash64(int[] data)
long
hash64(int[][] data)
long
hash64(int[] data, int length)
long
hash64(long[] data)
long
hash64(long[][] data)
static long
hash64(long seed, boolean[] data)
static long
hash64(long seed, byte[] data)
static long
hash64(long seed, char[] data)
static long
hash64(long seed, char[][] data)
static long
hash64(long seed, 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(long seed, double[] data)
static long
hash64(long seed, float[] data)
static long
hash64(long seed, int[] data)
static long
hash64(long seed, int[][] data)
static long
hash64(long seed, int[] data, int length)
static long
hash64(long seed, long[] data)
static long
hash64(long seed, long[][] data)
static long
hash64(long seed, short[] data)
static long
hash64(long seed, CharSequence data)
static long
hash64(long seed, CharSequence[] data)
static long
hash64(long seed, CharSequence[]... data)
static long
hash64(long seed, 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(long seed, Iterable<? extends CharSequence> data)
static long
hash64(long seed, Object data)
static long
hash64(long seed, Object[] data)
static long
hash64(long seed, List<? extends CharSequence> data)
long
hash64(short[] data)
long
hash64(CharSequence data)
long
hash64(CharSequence[] data)
long
hash64(CharSequence[]... data)
long
hash64(CharSequence data, int start, int end)
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).long
hash64(Iterable<? extends CharSequence> data)
long
hash64(Object data)
long
hash64(Object[] data)
long
hash64(List<? extends CharSequence> data)
static long
randomize(long seed)
Very similar to Pelican and related unary hashes; uses "xor rotate xor rotate" as an early step to mix any clustered bits all around the result, then the rest is like MurmurHash3's mixer.
-
Field Details
-
alpha
-
beta
-
gamma
-
delta
-
epsilon
-
zeta
-
eta
-
theta
-
iota
-
kappa
-
lambda
-
mu
-
nu
-
xi
-
omicron
-
pi
-
rho
-
sigma
-
tau
-
upsilon
-
phi
-
chi
-
psi
-
omega
-
alpha_
-
beta_
-
gamma_
-
delta_
-
epsilon_
-
zeta_
-
eta_
-
theta_
-
iota_
-
kappa_
-
lambda_
-
mu_
-
nu_
-
xi_
-
omicron_
-
pi_
-
rho_
-
sigma_
-
tau_
-
upsilon_
-
phi_
-
chi_
-
psi_
-
omega_
-
baal
-
agares
-
vassago
-
samigina
-
marbas
-
valefor
-
amon
-
barbatos
-
paimon
-
buer
-
gusion
-
sitri
-
beleth
-
leraje
-
eligos
-
zepar
-
botis
-
bathin
-
sallos
-
purson
-
marax
-
ipos
-
aim
-
naberius
-
glasya_labolas
-
bune
-
ronove
-
berith
-
astaroth
-
forneus
-
foras
-
asmoday
-
gaap
-
furfur
-
marchosias
-
stolas
-
phenex
-
halphas
-
malphas
-
raum
-
focalor
-
vepar
-
sabnock
-
shax
-
vine
-
bifrons
-
vual
-
haagenti
-
crocell
-
furcas
-
balam
-
alloces
-
caim
-
murmur
-
orobas
-
gremory
-
ose
-
amy
-
orias
-
vapula
-
zagan
-
valac
-
andras
-
flauros
-
andrealphus
-
kimaris
-
amdusias
-
belial
-
decarabia
-
seere
-
dantalion
-
andromalius
-
baal_
-
agares_
-
vassago_
-
samigina_
-
marbas_
-
valefor_
-
amon_
-
barbatos_
-
paimon_
-
buer_
-
gusion_
-
sitri_
-
beleth_
-
leraje_
-
eligos_
-
zepar_
-
botis_
-
bathin_
-
sallos_
-
purson_
-
marax_
-
ipos_
-
aim_
-
naberius_
-
glasya_labolas_
-
bune_
-
ronove_
-
berith_
-
astaroth_
-
forneus_
-
foras_
-
asmoday_
-
gaap_
-
furfur_
-
marchosias_
-
stolas_
-
phenex_
-
halphas_
-
malphas_
-
raum_
-
focalor_
-
vepar_
-
sabnock_
-
shax_
-
vine_
-
bifrons_
-
vual_
-
haagenti_
-
crocell_
-
furcas_
-
balam_
-
alloces_
-
caim_
-
murmur_
-
orobas_
-
gremory_
-
ose_
-
amy_
-
orias_
-
vapula_
-
zagan_
-
valac_
-
andras_
-
flauros_
-
andrealphus_
-
kimaris_
-
amdusias_
-
belial_
-
decarabia_
-
seere_
-
dantalion_
-
andromalius_
-
predefined
Has a length of 192, which may be relevant if automatically choosing a predefined hash functor.
-
-
Constructor Details
-
Method Details
-
randomize
Very similar to Pelican and related unary hashes; uses "xor rotate xor rotate" as an early step to mix any clustered bits all around the result, then the rest is like MurmurHash3's mixer.- Parameters:
seed
- any long; there is no fix point at 0- Returns:
- any long
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)- Returns:
- a 64-bit hash code for the requested section of data
-
hash64
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
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)- Returns:
- a 64-bit hash code for the requested section of data
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)- Returns:
- a 64-bit hash code for the requested section of data
-
hash
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
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)- Returns:
- a 64-bit hash code for the requested section of data
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)- Returns:
- a 64-bit hash code for the requested section of data
-
hash64
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
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)- Returns:
- a 64-bit hash code for the requested section of data
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash64
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
data
- the char array to hashstart
- the start of the section to hash (inclusive)end
- the end of the section to hash (exclusive)- Returns:
- a 64-bit hash code for the requested section of data
-
hash
Hashes only a subsection of the given data, starting at start (inclusive) and ending before end (exclusive).- Parameters:
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)- Returns:
- a 64-bit hash code for the requested section of data
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-
hash
-