Class KeyHasher


  • public class KeyHasher
    extends java.lang.Object
    Provides the ability to hash on multiple objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[] objects  
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyHasher​(int size)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object buildHashKey​(java.lang.Object[] objects, int[] indexes)
      Static method to return the object to hash on.
      boolean equals​(java.lang.Object obj)  
      java.lang.Object getObject​(int index)
      Get the object stored at the specified index.
      int hashCode()  
      void setObject​(int index, java.lang.Object object)
      Set array element at the specified index to the specified object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • objects

        private final java.lang.Object[] objects
    • Constructor Detail

      • KeyHasher

        public KeyHasher​(int size)
    • Method Detail

      • setObject

        public void setObject​(int index,
                              java.lang.Object object)
        Set array element at the specified index to the specified object.
        Parameters:
        index - The specified index
        object - The specified object.
      • getObject

        public java.lang.Object getObject​(int index)
        Get the object stored at the specified index.
        Parameters:
        index - The specified index.
        Returns:
        The object stored in the array element.
      • buildHashKey

        public static java.lang.Object buildHashKey​(java.lang.Object[] objects,
                                                    int[] indexes)
        Static method to return the object to hash on. (Object stored in specifed array, if only a single object, otherwise a KeyHasher wrapping the objects to hash on. (NOTE: We optimize for in-memory hash tables, hence we only create a wrapper when needed.)
        Parameters:
        objects - The array of objects to consider
        indexes - The indexes of the objects in the hash key.
        Returns:
        The object to hash on.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object