Interface Hasher<V>

All Known Implementing Classes:
IdentityHasher, NaturalHasher

public interface Hasher<V>
A Hasher provides an external means for producing hash codes and comparing objects for equality.
Author:
mf 2011.01.07
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(V va, V vb)
    Compare two objects for equality.
    int
    Return a hash for the specified object.
    static int
    mod(int n, int m)
    Calculate a modulo of two integer numbers.
    static long
    mod(long n, long m)
    Calculate a modulo of two long numbers.
  • Method Details

    • hashCode

      int hashCode(V v)
      Return a hash for the specified object.
      Parameters:
      v - the object to hash
      Returns:
      the hash
    • equals

      boolean equals(V va, V vb)
      Compare two objects for equality.
      Parameters:
      va - the first object to compare
      vb - the second object to compare
      Returns:
      true iff the object are equal
    • mod

      static int mod(int n, int m)
      Calculate a modulo of two integer numbers. For a positive dividend the result is the same as the Java remainder operation (n % m). For a negative dividend the result is still positive and equals to (n % m + m).
      Parameters:
      n - the dividend
      m - the divisor (must be positive)
      Returns:
      the modulo
    • mod

      static long mod(long n, long m)
      Calculate a modulo of two long numbers. For a positive dividend the result is the same as the Java remainder operation (n % m). For a negative dividend the result is still positive and equals to (n % m + m).
      Parameters:
      n - the dividend
      m - the divisor (must be positive)
      Returns:
      the modulo