Class HopscotchHashMap<K,​V>

  • All Implemented Interfaces:
    java.util.Map<K,​V>

    public class HopscotchHashMap<K,​V>
    extends ArrayMap<K,​V>
    Lookup on a table without collisions will require only single access, if there are collisions it will be limited to (number of collisions to particular bin + 1) and all those will lie in proximity (32 * reference size). Inserts can be O(n) in the worst case when we have to rehash whole table or search through close-to-full for an empty spot.

    Not thread safe (though, look-ups are safe when there are no concurrent modifications).

    See Also:
    Hopscotch hashing
    • Constructor Detail

      • HopscotchHashMap

        public HopscotchHashMap​(int initialCapacity)
    • Method Detail

      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in class ArrayMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in class ArrayMap<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in class ArrayMap<K,​V>