Interface Hash<T>

  • Type Parameters:
    T - the type of objects for which hashes may be generated
    All Known Implementing Classes:
    PerfectStringHash

    public interface Hash<T>

    Implementations of this interface can generate one hash value for a given object. Depending upon the implementation, null values may be supported.

    Author:
    tomgibara
    • Method Detail

      • hashAsBigInt

        BigInteger hashAsBigInt​(T value)
                         throws IllegalArgumentException
        The hash value as a BigInteger. This method may be useful in circumstances where the generated hash is too large to be accomodated in a single primitive value, eg. if cryptographic hashes are being used.
        Parameters:
        value - the object to be hashed
        Returns:
        the object's hash code, never null
        Throws:
        IllegalArgumentException - if the value cannot be hashed
      • hashAsInt

        int hashAsInt​(T value)
               throws IllegalArgumentException
        The hash value as an int. This method should provide better performance for integer-ranged hashes. This value is not guaranteed to lie within the indicated HashRange.
        Parameters:
        value - the object to be hashed
        Returns:
        the object's hash code
        Throws:
        IllegalArgumentException - if the value cannot be hashed
      • hashAsLong

        long hashAsLong​(T value)
                 throws IllegalArgumentException
        The hash value as a long. This method should provide better performance for long-ranged hashes. This value is not guaranteed to lie within the indicated HashRange.
        Parameters:
        value - the object to be hashed
        Returns:
        the object's hash code
        Throws:
        IllegalArgumentException - if the value cannot be hashed