Package edu.uiuc.ncsa.security.core.util
Class DoubleHashMap<K,V>
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.util.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 withgetByValue(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 Summary
Constructors Constructor Description DoubleHashMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)KgetByValue(V value)booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)Slow since this loops.Vremove(Object key)intsize()Collection<V>values()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<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.
-
-