Class CuckooHashing<T>

  • Type Parameters:
    T - class of stored elements

    public class CuckooHashing<T>
    extends Object
    Provides a hash table based on Cuckoo Hashing. Citation: Rasmus Pagh, Flemming Friche Rodler: Cuckoo Hashing. ESA 2001: 121-133
    • Constructor Detail

      • CuckooHashing

        public CuckooHashing​(int startHashSize,
                             int maxStashSize,
                             int startNumTables,
                             Random random)
        Creates a new hash table based on Cuckoo Hashing.
        Parameters:
        startHashSize - size of the hash function at the beginning (must be smaller than 31)
        maxStashSize - maximum size of the stash
        startNumTables - number of tables for Cuckoo hashing
        random - instance to generate a stream of pseudorandom numbers
      • CuckooHashing

        public CuckooHashing​(int hashSize,
                             Random random)
        Creates a new hash table based on Cuckoo Hashing.
        Parameters:
        hashSize - size of the hash function
        random - instance to generate a stream of pseudorandom numbers
    • Method Detail

      • put

        public void put​(long key,
                        T element)
        Adds an element to the hash table.
        Parameters:
        key - key value of the element
        element - value of the element
      • get

        public T get​(long key)
        Gets an element of the hash table.
        Parameters:
        key - key value of the element
      • clear

        public void clear()
        Removes all of the elements from this hash table. The hash table will be empty after this call returns.
      • size

        public int size()
        Returns the number of elements in the hash table.
        Returns:
        the number of elements in the hash table
      • isEmpty

        public boolean isEmpty()
        Returns true if this hash table contains no elements.
        Returns:
        true if this hash table contains no elements