Class CRC16

java.lang.Object
org.infinispan.commons.hash.CRC16
All Implemented Interfaces:
Hash

@ThreadSafe @Immutable public class CRC16 extends Object implements Hash
A CRC16 implementation in Java.
Since:
15.0
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static CRC16
     
    int
    hash(byte[] payload)
    Hashes a byte array efficiently.
    int
    hash(int hashcode)
    An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived from Object.hashCode().
    int
    A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).
    int
    How many bits this hash function may utilize.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getInstance

      public static CRC16 getInstance()
    • hash

      public int hash(byte[] payload)
      Description copied from interface: Hash
      Hashes a byte array efficiently.
      Specified by:
      hash in interface Hash
      Parameters:
      payload - a byte array to hash
      Returns:
      a hash code for the byte array
    • maxHashBits

      public int maxHashBits()
      Description copied from interface: Hash
      How many bits this hash function may utilize. By default a hash algorithm is assumed to use all 32 bits producing a value in the full range of int values.
      Specified by:
      maxHashBits in interface Hash
      Returns:
      how many bits the resulting int may use
    • hash

      public int hash(int hashcode)
      Description copied from interface: Hash
      An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived from Object.hashCode().
      Specified by:
      hash in interface Hash
      Parameters:
      hashcode - an object's hashcode
      Returns:
      a spread and hashed version of the hashcode
    • hash

      public int hash(Object o)
      Description copied from interface: Hash
      A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).
      Specified by:
      hash in interface Hash
      Parameters:
      o - object to hash
      Returns:
      a hashcode
    • toString

      public String toString()
      Overrides:
      toString in class Object