Class DoubleHashMap<K,​V>

  • All Implemented Interfaces:
    Serializable, Map<K,​V>

    public class DoubleHashMap<K,​V>
    extends Object
    implements Map<K,​V>, Serializable
    A hashmap with two-way lookup. This maintains a second hashmap that has the keys reversed. Access these elements with getByValue(Object). There are some caveats. For one thing, this assumes that there is a one to one correspondence between keys and values so this specifically dis-allows null objects as values. Multiple values will get over-written. with "predictable but unwanted results."

    Created by Jeff Gaynor
    on 3/1/12 at 2:06 PM

    See Also:
    Serialized Form
    • Constructor Detail

      • DoubleHashMap

        public DoubleHashMap()
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface Map<K,​V>
      • size

        public int size()
        Specified by:
        size in interface Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Map<K,​V>
      • containsKey

        public boolean containsKey​(Object key)
        Specified by:
        containsKey in interface Map<K,​V>
      • get

        public V get​(Object key)
        Specified by:
        get in interface Map<K,​V>
      • put

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

        public V remove​(Object key)
        Specified by:
        remove in interface Map<K,​V>
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Slow since this loops. Best to over-ride if you performance is an issue.
        Specified by:
        putAll in interface Map<K,​V>
        Parameters:
        m -
      • keySet

        public Set<K> keySet()
        Specified by:
        keySet in interface Map<K,​V>
      • getByValue

        public K getByValue​(V value)