Class Hasher

java.lang.Object
com.github.tommyettinger.digital.Hasher

public class Hasher extends Object
64-bit and 32-bit hashing functions that we can rely on staying the same cross-platform. This uses a family of algorithms all based on Wang Yi's wyhash, but using at most 64-bit math. Wyhash was designed foremost for speed and also general-purpose usability, but not cryptographic security. The functions here pass the stringent SMHasher test battery, including the "bad seeds" test that wyhash itself fails.
This provides an object-based API and a static API, where a Hasher object is instantiated with a seed, and the static methods take a seed as their first argument. The hashes this returns are always 0 when given null to hash. Arrays with identical elements of identical types will hash identically. Arrays with identical numerical values but different types will sometimes hash differently. This class always provides 64-bit hashes via hash64() and 32-bit hashes via hash(). The hash64() and hash() methods use 64-bit math even when producing 32-bit hashes, for GWT reasons. GWT doesn't have the same behavior as desktop and Android applications when using ints because it treats ints mostly like doubles, sometimes, due to it using JavaScript. If we use mainly longs, though, GWT emulates the longs with a more complex technique behind-the-scenes, that behaves the same on the web as it does on desktop or on a phone. Since Hasher is supposed to be stable cross-platform, this is the way we need to go, despite it being slightly slower.
This class also provides static randomize1(long), randomize2(long), and randomize3(long) methods, which are unary hashes (hashes of one item, a number) with variants such as randomize1Bounded(long, int) and randomize2Float(long). The randomize1() methods are faster but more sensitive to patterns in their input; they are meant to work well on sequential inputs, like 1, 2, 3, etc. with relatively-short sequences (ideally under a million, but if statistical quality isn't a concern, they can handle any length). The randomize2() methods are more-involved, but should be able to handle most kinds of input pattern across even rather-large sequences (billions) while returning random results. The randomize3() methods are likely complete overkill for many cases, but provide extremely strong randomization for any possible input pattern, using the MX3 unary hash with an extra XOR at the beginning to prevent a fixed point at 0.
There are also 192 predefined instances of Hasher that you can either select from the array predefined or select by hand, such as omega. The predefined instances are named after the 24 greek letters, then the same letters with a trailing underscore, then 72 names of demons from the Ars Goetia, then the names of those demons with trailing underscores. The greek letters are traditional, and the demons are perfectly fitting for video games.
  • Field Details

    • seed

      public final long seed
      The seed used by all non-static hash() and hash64() methods in this class (the methods that don't take a seed). You can create many different Hasher objects, all with different seeds, and get very different hashes as a result of any calls on them. Because making this field hidden in some way doesn't meaningfully contribute to security, and only makes it harder to use this class, seed is public (and final, so it can't be accidentally modified, but still can if needed via reflection).
    • b0

      public static final long b0
      Big constant 0.
      See Also:
    • b1

      public static final long b1
      Big constant 1.
      See Also:
    • b2

      public static final long b2
      Big constant 2.
      See Also:
    • b3

      public static final long b3
      Big constant 3.
      See Also:
    • b4

      public static final long b4
      Big constant 4.
      See Also:
    • b5

      public static final long b5
      Big constant 5.
      See Also:
    • alpha

      public static final Hasher alpha
    • beta

      public static final Hasher beta
    • gamma

      public static final Hasher gamma
    • delta

      public static final Hasher delta
    • epsilon

      public static final Hasher epsilon
    • zeta

      public static final Hasher zeta
    • eta

      public static final Hasher eta
    • theta

      public static final Hasher theta
    • iota

      public static final Hasher iota
    • kappa

      public static final Hasher kappa
    • lambda

      public static final Hasher lambda
    • mu

      public static final Hasher mu
    • nu

      public static final Hasher nu
    • xi

      public static final Hasher xi
    • omicron

      public static final Hasher omicron
    • pi

      public static final Hasher pi
    • rho

      public static final Hasher rho
    • sigma

      public static final Hasher sigma
    • tau

      public static final Hasher tau
    • upsilon

      public static final Hasher upsilon
    • phi

      public static final Hasher phi
    • chi

      public static final Hasher chi
    • psi

      public static final Hasher psi
    • omega

      public static final Hasher omega
    • alpha_

      public static final Hasher alpha_
    • beta_

      public static final Hasher beta_
    • gamma_

      public static final Hasher gamma_
    • delta_

      public static final Hasher delta_
    • epsilon_

      public static final Hasher epsilon_
    • zeta_

      public static final Hasher zeta_
    • eta_

      public static final Hasher eta_
    • theta_

      public static final Hasher theta_
    • iota_

      public static final Hasher iota_
    • kappa_

      public static final Hasher kappa_
    • lambda_

      public static final Hasher lambda_
    • mu_

      public static final Hasher mu_
    • nu_

      public static final Hasher nu_
    • xi_

      public static final Hasher xi_
    • omicron_

      public static final Hasher omicron_
    • pi_

      public static final Hasher pi_
    • rho_

      public static final Hasher rho_
    • sigma_

      public static final Hasher sigma_
    • tau_

      public static final Hasher tau_
    • upsilon_

      public static final Hasher upsilon_
    • phi_

      public static final Hasher phi_
    • chi_

      public static final Hasher chi_
    • psi_

      public static final Hasher psi_
    • omega_

      public static final Hasher omega_
    • baal

      public static final Hasher baal
    • agares

      public static final Hasher agares
    • vassago

      public static final Hasher vassago
    • samigina

      public static final Hasher samigina
    • marbas

      public static final Hasher marbas
    • valefor

      public static final Hasher valefor
    • amon

      public static final Hasher amon
    • barbatos

      public static final Hasher barbatos
    • paimon

      public static final Hasher paimon
    • buer

      public static final Hasher buer
    • gusion

      public static final Hasher gusion
    • sitri

      public static final Hasher sitri
    • beleth

      public static final Hasher beleth
    • leraje

      public static final Hasher leraje
    • eligos

      public static final Hasher eligos
    • zepar

      public static final Hasher zepar
    • botis

      public static final Hasher botis
    • bathin

      public static final Hasher bathin
    • sallos

      public static final Hasher sallos
    • purson

      public static final Hasher purson
    • marax

      public static final Hasher marax
    • ipos

      public static final Hasher ipos
    • aim

      public static final Hasher aim
    • naberius

      public static final Hasher naberius
    • glasya_labolas

      public static final Hasher glasya_labolas
    • bune

      public static final Hasher bune
    • ronove

      public static final Hasher ronove
    • berith

      public static final Hasher berith
    • astaroth

      public static final Hasher astaroth
    • forneus

      public static final Hasher forneus
    • foras

      public static final Hasher foras
    • asmoday

      public static final Hasher asmoday
    • gaap

      public static final Hasher gaap
    • furfur

      public static final Hasher furfur
    • marchosias

      public static final Hasher marchosias
    • stolas

      public static final Hasher stolas
    • phenex

      public static final Hasher phenex
    • halphas

      public static final Hasher halphas
    • malphas

      public static final Hasher malphas
    • raum

      public static final Hasher raum
    • focalor

      public static final Hasher focalor
    • vepar

      public static final Hasher vepar
    • sabnock

      public static final Hasher sabnock
    • shax

      public static final Hasher shax
    • vine

      public static final Hasher vine
    • bifrons

      public static final Hasher bifrons
    • vual

      public static final Hasher vual
    • haagenti

      public static final Hasher haagenti
    • crocell

      public static final Hasher crocell
    • furcas

      public static final Hasher furcas
    • balam

      public static final Hasher balam
    • alloces

      public static final Hasher alloces
    • caim

      public static final Hasher caim
    • murmur

      public static final Hasher murmur
    • orobas

      public static final Hasher orobas
    • gremory

      public static final Hasher gremory
    • ose

      public static final Hasher ose
    • amy

      public static final Hasher amy
    • orias

      public static final Hasher orias
    • vapula

      public static final Hasher vapula
    • zagan

      public static final Hasher zagan
    • valac

      public static final Hasher valac
    • andras

      public static final Hasher andras
    • flauros

      public static final Hasher flauros
    • andrealphus

      public static final Hasher andrealphus
    • kimaris

      public static final Hasher kimaris
    • amdusias

      public static final Hasher amdusias
    • belial

      public static final Hasher belial
    • decarabia

      public static final Hasher decarabia
    • seere

      public static final Hasher seere
    • dantalion

      public static final Hasher dantalion
    • andromalius

      public static final Hasher andromalius
    • baal_

      public static final Hasher baal_
    • agares_

      public static final Hasher agares_
    • vassago_

      public static final Hasher vassago_
    • samigina_

      public static final Hasher samigina_
    • marbas_

      public static final Hasher marbas_
    • valefor_

      public static final Hasher valefor_
    • amon_

      public static final Hasher amon_
    • barbatos_

      public static final Hasher barbatos_
    • paimon_

      public static final Hasher paimon_
    • buer_

      public static final Hasher buer_
    • gusion_

      public static final Hasher gusion_
    • sitri_

      public static final Hasher sitri_
    • beleth_

      public static final Hasher beleth_
    • leraje_

      public static final Hasher leraje_
    • eligos_

      public static final Hasher eligos_
    • zepar_

      public static final Hasher zepar_
    • botis_

      public static final Hasher botis_
    • bathin_

      public static final Hasher bathin_
    • sallos_

      public static final Hasher sallos_
    • purson_

      public static final Hasher purson_
    • marax_

      public static final Hasher marax_
    • ipos_

      public static final Hasher ipos_
    • aim_

      public static final Hasher aim_
    • naberius_

      public static final Hasher naberius_
    • glasya_labolas_

      public static final Hasher glasya_labolas_
    • bune_

      public static final Hasher bune_
    • ronove_

      public static final Hasher ronove_
    • berith_

      public static final Hasher berith_
    • astaroth_

      public static final Hasher astaroth_
    • forneus_

      public static final Hasher forneus_
    • foras_

      public static final Hasher foras_
    • asmoday_

      public static final Hasher asmoday_
    • gaap_

      public static final Hasher gaap_
    • furfur_

      public static final Hasher furfur_
    • marchosias_

      public static final Hasher marchosias_
    • stolas_

      public static final Hasher stolas_
    • phenex_

      public static final Hasher phenex_
    • halphas_

      public static final Hasher halphas_
    • malphas_

      public static final Hasher malphas_
    • raum_

      public static final Hasher raum_
    • focalor_

      public static final Hasher focalor_
    • vepar_

      public static final Hasher vepar_
    • sabnock_

      public static final Hasher sabnock_
    • shax_

      public static final Hasher shax_
    • vine_

      public static final Hasher vine_
    • bifrons_

      public static final Hasher bifrons_
    • vual_

      public static final Hasher vual_
    • haagenti_

      public static final Hasher haagenti_
    • crocell_

      public static final Hasher crocell_
    • furcas_

      public static final Hasher furcas_
    • balam_

      public static final Hasher balam_
    • alloces_

      public static final Hasher alloces_
    • caim_

      public static final Hasher caim_
    • murmur_

      public static final Hasher murmur_
    • orobas_

      public static final Hasher orobas_
    • gremory_

      public static final Hasher gremory_
    • ose_

      public static final Hasher ose_
    • amy_

      public static final Hasher amy_
    • orias_

      public static final Hasher orias_
    • vapula_

      public static final Hasher vapula_
    • zagan_

      public static final Hasher zagan_
    • valac_

      public static final Hasher valac_
    • andras_

      public static final Hasher andras_
    • flauros_

      public static final Hasher flauros_
    • andrealphus_

      public static final Hasher andrealphus_
    • kimaris_

      public static final Hasher kimaris_
    • amdusias_

      public static final Hasher amdusias_
    • belial_

      public static final Hasher belial_
    • decarabia_

      public static final Hasher decarabia_
    • seere_

      public static final Hasher seere_
    • dantalion_

      public static final Hasher dantalion_
    • andromalius_

      public static final Hasher andromalius_
    • predefined

      public static final Hasher[] predefined
      Has a length of 192, which may be relevant if automatically choosing a predefined hash functor.
  • Constructor Details

    • Hasher

      public Hasher()
      Creates a new Hasher seeded, arbitrarily, with the constant 0xC4CEB9FE1A85EC53L, or -4265267296055464877L .
    • Hasher

      public Hasher(long seed)
      Initializes this Hasher with the given seed, verbatim; it is recommended to use randomize3(long) on the seed if you don't know if it is adequately-random. If the seed is the same for two different Hasher instances and they are given the same inputs, they will produce the same results. If the seed is even slightly different, the results of the two Hashers given the same input should be significantly different.
      Parameters:
      seed - a long that will be used to change the output of hash() and hash64() methods on the new Hasher
    • Hasher

      public Hasher(CharSequence seed)
      Constructs a Hasher by hashing seed with hash64(long, CharSequence), and then running the result through randomize2(long). This is the same as calling the constructor Hasher(long) and passing it randomize2(hash64(1L, seed)) .
      Parameters:
      seed - a CharSequence, such as a String, that will be used to seed the Hasher.
  • Method Details

    • randomize1

      public static long randomize1(long state)
      Fast static randomizing method that takes its state as a parameter; state is expected to change between calls to this. It is recommended that you use randomize1(++state) or randomize1(--state) to produce a sequence of different numbers, and you may have slightly worse quality with increments or decrements other than 1. All longs are accepted by this method, and all longs can be produced. Passing 0 here does not cause this to return 0.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      Returns:
      any long
    • randomize2

      public static long randomize2(long state)
      Mid-quality static randomizing method that takes its state as a parameter; state is expected to change between calls to this. It is suggested that you use DiverRNG.randomize(++state) or DiverRNG.randomize(--state) to produce a sequence of different numbers, but any increments are allowed (even-number increments won't be able to produce all outputs, but their quality will be fine for the numbers they can produce). All longs are accepted by this method, and all longs can be produced. Passing 0 here does not cause this to return 0.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      Returns:
      any long
    • randomize3

      public static long randomize3(long state)
      Very thorough static randomizing method that takes its state as a parameter; state is expected to change between calls to this. It is suggested that you use randomize3(++state) or randomize3(--state) to produce a sequence of different numbers, but any odd-number increment should work well, as could another source of different longs, such as a flawed random number generator. All longs are accepted by this method, and all longs can be produced. Passing 0 here does not cause this to return 0.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      Returns:
      any long
    • randomize1Bounded

      public static int randomize1Bounded(long state, int bound)
      Fast static randomizing method that takes its state as a parameter and limits output to an int between 0 (inclusive) and bound (exclusive); state is expected to change between calls to this. It is recommended that you use randomize1Bounded(++state, bound) or randomize1Bounded(--state, bound) to produce a sequence of different numbers. All longs are accepted by this method, but not all ints between 0 and bound are guaranteed to be produced with equal likelihood (for any odd-number values for bound, this isn't possible for most generators). The bound can be negative.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      bound - the outer exclusive bound, as an int
      Returns:
      an int between 0 (inclusive) and bound (exclusive)
    • randomize2Bounded

      public static int randomize2Bounded(long state, int bound)
      Mid-quality static randomizing method that takes its state as a parameter and limits output to an int between 0 (inclusive) and bound (exclusive); state is expected to change between calls to this. It is suggested that you use randomize2Bounded(++state) or randomize2Bounded(--state) to produce a sequence of different numbers, but any increments are allowed (even-number increments won't be able to produce all outputs, but their quality will be fine for the numbers they can produce). All longs are accepted by this method, but not all ints between 0 and bound are guaranteed to be produced with equal likelihood (for any odd-number values for bound, this isn't possible for most generators). The bound can be negative.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      bound - the outer exclusive bound, as an int
      Returns:
      an int between 0 (inclusive) and bound (exclusive)
    • randomize3Bounded

      public static int randomize3Bounded(long state, int bound)
      Very thorough static randomizing method that takes its state as a parameter and limits output to an int between 0 (inclusive) and bound (exclusive); state is expected to change between calls to this. It is suggested that you use randomize3Bounded(++state) or randomize3(--state) to produce a sequence of different numbers, but any increments are allowed (even-number increments won't be able to produce all outputs, but their quality will be fine for the numbers they can produce). All longs are accepted by this method, but not all ints between 0 and bound are guaranteed to be produced with equal likelihood (for any odd-number values for bound, this isn't possible for most generators). The bound can be negative.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - any long; subsequent calls should change by an odd number, such as with ++state
      bound - the outer exclusive bound, as an int
      Returns:
      an int between 0 (inclusive) and bound (exclusive)
    • randomize1Float

      public static float randomize1Float(long state)
      Returns a random float that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize1Float(++state), where the increment for state should generally be 1. The period is 2 to the 64 if you increment or decrement by 1, but there are only 2 to the 30 possible floats between 0 and 1, and this can only return 2 to the 24 of them (a requirement for the returned values to be uniform).
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomize1Float(++state) is recommended to go forwards or randomize1Float(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random float between 0f (inclusive) and 1f (exclusive), determined by state
    • randomize2Float

      public static float randomize2Float(long state)
      Returns a random float that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize2Float(++state), where the increment for state can be any value and should usually be odd (even-number increments reduce the period). The period is 2 to the 64 if you increment or decrement by any odd number, but there are only 2 to the 30 possible floats between 0 and 1, and this can only return 2 to the 24 of them (a requirement for the returned values to be uniform).
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomize2Float(++state) is recommended to go forwards or randomize2Float(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random float between 0f (inclusive) and 1f (exclusive), determined by state
    • randomize3Float

      public static float randomize3Float(long state)
      Returns a random float that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize3Float(++state), where the increment for state can be any value and should usually be odd (even-number increments reduce the period). The period is 2 to the 64 if you increment or decrement by any odd number, but there are only 2 to the 30 possible floats between 0 and 1, and this can only return 2 to the 24 of them (a requirement for the returned values to be uniform).
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomize3Float(++state) is recommended to go forwards or randomize3Float(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random float between 0f (inclusive) and 1f (exclusive), determined by state
    • randomize1Double

      public static double randomize1Double(long state)
      Returns a random double that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize1Double(++state), where the increment for state should generally be 1. The period is 2 to the 64 if you increment or decrement by 1, but there are only 2 to the 62 possible doubles between 0 and 1.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomize1Double(++state) is recommended to go forwards or randomize1Double(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random double between 0.0 (inclusive) and 1.0 (exclusive), determined by state
    • randomize2Double

      public static double randomize2Double(long state)
      Returns a random double that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize2Double(++state), where the increment for state can be any number but should usually be odd (even-number increments reduce the period). The period is 2 to the 64 if you increment or decrement by 1, but there are only 2 to the 62 possible doubles between 0 and 1.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomizeDouble(++state) is recommended to go forwards or randomizeDouble(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random double between 0.0 (inclusive) and 1.0 (exclusive), determined by state
    • randomize3Double

      public static double randomize3Double(long state)
      Returns a random double that is deterministic based on state; if state is the same on two calls to this, this will return the same float. This is expected to be called with a changing variable, e.g. randomize3Double(++state), where the increment for state can be any number but should usually be odd (even-number increments reduce the period). The period is 2 to the 64 if you increment or decrement by 1, but there are only 2 to the 62 possible doubles between 0 and 1.
      You have a choice between different randomize strengths in this class. randomize1() is simpler, and will behave well when the inputs are sequential, while randomize2() is a completely different algorithm, Pelle Evensen's xNASAM; it will have excellent quality for most patterns in input but will be about 30% slower than randomize1(), though this is rarely detectable. randomize3() is the slowest and most robust; it uses MX3 by Jon Maiga, which the aforementioned author of xNASAM now recommends for any unary hashing. All randomizeN methods will produce all long outputs if given all possible longs as input. Technically-speaking, randomize1(long), randomize2(long), and randomize3(long) are bijective functions, which means they are reversible; it is, however, somewhat harder to reverse the xor-rotate-xor-rotate stage used in randomize2() (reversing randomize3() is easy, but takes more steps), and the methods that produce any output other than a full-range long are not reversible (such as randomize1Bounded(long, int) and randomize2Double(long)).
      Parameters:
      state - a variable that should be different every time you want a different random result; using randomize3Double(++state) is recommended to go forwards or randomize3Double(--state) to generate numbers in reverse order
      Returns:
      a pseudo-random double between 0.0 (inclusive) and 1.0 (exclusive), determined by state
    • mum

      public 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. The arguments and result are only technically longs because their lower 32 bits matter much more than their upper 32, and giving just any long won't work.
      This is very similar to wyhash's mum function, but doesn't use 128-bit math because it expects that its arguments are only relevant in their lower 32 bits (allowing their product to fit in 64 bits).
      Parameters:
      a - a long that should probably only hold an int's worth of data
      b - a long that should probably only hold an int's worth of data
      Returns:
      a sort-of randomized output dependent on both inputs
    • wow

      public 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.
      This was changed so that it distributes bits from both inputs a little better on July 6, 2019.
      Parameters:
      a - any long
      b - any long
      Returns:
      a sort-of randomized output dependent on both inputs
    • hash64

      public long hash64(boolean[] data)
    • hash64

      public long hash64(byte[] data)
    • hash64

      public long hash64(short[] data)
    • hash64

      public long hash64(char[] data)
    • hash64

      public long hash64(CharSequence data)
    • hash64

      public long hash64(int[] data)
    • hash64

      public long hash64(int[] data, int length)
    • hash64

      public long hash64(long[] data)
    • hash64

      public long hash64(float[] data)
    • hash64

      public long hash64(double[] data)
    • hash64

      public 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).
      Parameters:
      data - the char array to hash
      start - 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

      public 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).
      Parameters:
      data - the String or other CharSequence to hash
      start - 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

      public long hash64(byte[][] data)
    • hash64

      public long hash64(char[][] data)
    • hash64

      public long hash64(float[][] data)
    • hash64

      public long hash64(double[][] data)
    • hash64

      public long hash64(int[][] data)
    • hash64

      public long hash64(long[][] data)
    • hash64

      public long hash64(CharSequence[] data)
    • hash64

      public long hash64(CharSequence[]... data)
    • hash64

      public long hash64(Iterable<? extends CharSequence> data)
    • hash64

      public long hash64(List<? extends CharSequence> data)
    • hash64

      public long hash64(Object[] data)
    • hash64

      public long hash64(Object data)
    • hash

      public int hash(boolean[] data)
    • hash

      public int hash(byte[] data)
    • hash

      public int hash(short[] data)
    • hash

      public int hash(char[] data)
    • hash

      public int hash(CharSequence data)
    • hash

      public int hash(int[] data)
    • hash

      public int hash(int[] data, int length)
    • hash

      public int hash(long[] data)
    • hash

      public int hash(float[] data)
    • hash

      public int hash(double[] data)
    • hash

      public 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).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public 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).
      Parameters:
      data - the String or other CharSequence to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public int hash(byte[][] data)
    • hash

      public int hash(char[][] data)
    • hash

      public int hash(float[][] data)
    • hash

      public int hash(double[][] data)
    • hash

      public int hash(int[][] data)
    • hash

      public int hash(long[][] data)
    • hash

      public int hash(CharSequence[] data)
    • hash

      public int hash(CharSequence[]... data)
    • hash

      public int hash(Iterable<? extends CharSequence> data)
    • hash

      public int hash(List<? extends CharSequence> data)
    • hash

      public int hash(Object[] data)
    • hash

      public int hash(Object data)
    • hash64

      public static long hash64(long seed, boolean[] data)
    • hash64

      public static long hash64(long seed, byte[] data)
    • hash64

      public static long hash64(long seed, short[] data)
    • hash64

      public static long hash64(long seed, char[] data)
    • hash64

      public static long hash64(long seed, CharSequence data)
    • hash64

      public static long hash64(long seed, int[] data)
    • hash64

      public static long hash64(long seed, int[] data, int length)
    • hash64

      public static long hash64(long seed, long[] data)
    • hash64

      public static long hash64(long seed, float[] data)
    • hash64

      public static long hash64(long seed, double[] data)
    • hash64

      public 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).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash64

      public 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).
      Parameters:
      data - the String or other CharSequence to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash64

      public static long hash64(long seed, byte[][] data)
    • hash64

      public static long hash64(long seed, char[][] data)
    • hash64

      public static long hash64(long seed, float[][] data)
    • hash64

      public static long hash64(long seed, double[][] data)
    • hash64

      public static long hash64(long seed, int[][] data)
    • hash64

      public static long hash64(long seed, long[][] data)
    • hash64

      public static long hash64(long seed, CharSequence[] data)
    • hash64

      public static long hash64(long seed, CharSequence[]... data)
    • hash64

      public static long hash64(long seed, Iterable<? extends CharSequence> data)
    • hash64

      public static long hash64(long seed, List<? extends CharSequence> data)
    • hash64

      public static long hash64(long seed, Object[] data)
    • hash64

      public static long hash64(long seed, Object data)
    • hash

      public static int hash(long seed, boolean[] data)
    • hash

      public static int hash(long seed, byte[] data)
    • hash

      public static int hash(long seed, short[] data)
    • hash

      public static int hash(long seed, char[] data)
    • hash

      public static int hash(long seed, CharSequence data)
    • hash

      public static int hash(long seed, int[] data)
    • hash

      public static int hash(long seed, int[] data, int length)
    • hash

      public static int hash(long seed, long[] data)
    • hash

      public static int hash(long seed, float[] data)
    • hash

      public static int hash(long seed, double[] data)
    • hash

      public 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).
      Parameters:
      data - the char array to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public 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).
      Parameters:
      data - the String or other CharSequence to hash
      start - the start of the section to hash (inclusive)
      end - the end of the section to hash (exclusive)
      Returns:
      a 32-bit hash code for the requested section of data
    • hash

      public static int hash(long seed, byte[][] data)
    • hash

      public static int hash(long seed, char[][] data)
    • hash

      public static int hash(long seed, float[][] data)
    • hash

      public static int hash(long seed, double[][] data)
    • hash

      public static int hash(long seed, int[][] data)
    • hash

      public static int hash(long seed, long[][] data)
    • hash

      public static int hash(long seed, CharSequence[] data)
    • hash

      public static int hash(long seed, CharSequence[]... data)
    • hash

      public static int hash(long seed, Iterable<? extends CharSequence> data)
    • hash

      public static int hash(long seed, List<? extends CharSequence> data)
    • hash

      public static int hash(long seed, Object[] data)
    • hash

      public static int hash(long seed, Object data)