Module hash4j

Interface Hasher64

All Superinterfaces:
Hasher32
All Known Subinterfaces:
Hasher128

public interface Hasher64 extends Hasher32
A 64-bit hash function.

Instances are immutable. Therefore, it is safe to use a single instance across multiple threads and for multiple hash calculations.

Implementations must ensure that

(int)hashToLong(T, com.dynatrace.hash4j.hashing.HashFunnel<T>)(obj, funnel) == Hasher32.hashToInt(T, com.dynatrace.hash4j.hashing.HashFunnel<T>)(obj, funnel)

  • Method Details

    • hashStream

      HashStream64 hashStream()
      Starts a hash stream.
      Specified by:
      hashStream in interface Hasher32
      Returns:
      a new HashStream64 instance
    • hashStreamFromState

      HashStream64 hashStreamFromState(byte[] state)
      Reconstructs a hash stream from a given state.

      The behavior is undefined, if the given state was not created by a hash stream of a hasher that is equal to this hasher.

      Specified by:
      hashStreamFromState in interface Hasher32
      Returns:
      a new HashStream64 instance
    • hashToLong

      <T> long hashToLong(T obj, HashFunnel<T> funnel)
      Hashes an object to a 64-bit long value.
      Type Parameters:
      T - the type
      Parameters:
      obj - the object
      funnel - the funnel
      Returns:
      the hash value
    • hashBytesToLong

      long hashBytesToLong(byte[] input)
      Hashes a byte array to a 64-bit long value.

      Equivalent to hashBytesToLong(input, 0, input.length).

      Parameters:
      input - the byte array
      Returns:
      the hash value
    • hashBytesToLong

      long hashBytesToLong(byte[] input, int off, int len)
      Hashes a byte array to a 64-bit long value.

      Equivalent to hashToLong(input, (b, f) -> f.putBytes(b, off, len)).

      Parameters:
      input - the byte array
      off - the offset
      len - the length
      Returns:
      the hash value
    • hashBytesToLong

      <T> long hashBytesToLong(T input, long off, long len, ByteAccess<T> access)
      Hashes a sequence of bytes to a 64-bit long value
      Type Parameters:
      T - the type of the input
      Parameters:
      input - the input
      off - the offset
      len - the length
      access - a strategy to access the bytes of the input
      Returns:
      the hash value
    • hashCharsToLong

      long hashCharsToLong(CharSequence input)
      Hashes a CharSequence to a 64-bit long value.

      Equivalent to hashToLong(input, (c, f) -> f.putChars(c)).

      Parameters:
      input - the char sequence
      Returns:
      the hash value
    • hashIntToLong

      long hashIntToLong(int v)
      Hashes a 32-bit int value into a 64-bit long value.

      Equivalent to hashStream().putInt(v).getAsInt();

      Parameters:
      v - value
      Returns:
      the hash value
    • hashIntIntToLong

      long hashIntIntToLong(int v1, int v2)
      Hashes/Mixes two 32-bit int values into a 64-bit long value.

      Equivalent to hashStream().putInt(v1).putInt(v2).getAsInt();

      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      the hash value
    • hashIntIntIntToLong

      long hashIntIntIntToLong(int v1, int v2, int v3)
      Hashes/Mixes three 32-bit int values into a 64-bit long value.

      Equivalent to hashStream().putInt(v1).putInt(v2).putInt(v3).getAsLong();

      Parameters:
      v1 - first value
      v2 - second value
      v3 - third value
      Returns:
      the hash value
    • hashIntLongToLong

      long hashIntLongToLong(int v1, long v2)
      Hashes/Mixes a 32-bit int value and a 64-bit long value into a 64-bit long value.

      Equivalent to hashStream().putInt(v1).putLong(v2).getAsLong();

      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      the hash value
    • hashLongToLong

      long hashLongToLong(long v)
      Hashes a 64-bit long value into a 64-bit long value.

      Equivalent to hashStream().putLong(v).getAsInt();

      Parameters:
      v - value
      Returns:
      the hash value
    • hashLongLongToLong

      long hashLongLongToLong(long v1, long v2)
      Hashes/Mixes two 64-bit long values into a 64-bit long value.

      Equivalent to hashStream().putLong(v1).putLong(v2).getAsLong();

      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      the hash value
    • hashLongLongLongToLong

      long hashLongLongLongToLong(long v1, long v2, long v3)
      Hashes/Mixes three 64-bit long values into a 64-bit long value.

      Equivalent to hashStream().putLong(v1).putLong(v2).putLong(v3).getAsLong();

      Parameters:
      v1 - first value
      v2 - second value
      v3 - third value
      Returns:
      the hash value
    • hashLongIntToLong

      long hashLongIntToLong(long v1, int v2)
      Hashes/Mixes a 64-bit long value and a 32-bit int value into a 64-bit long value.

      Equivalent to hashStream().putLong(v1).putInt(v2).getAsLong();

      Parameters:
      v1 - first value
      v2 - second value
      Returns:
      the hash value
    • getHashBitSize

      int getHashBitSize()
      The size of the hash value in bits.
      Returns:
      the size of the hash value in bits