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 void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
K
getByValue(V value)
boolean
isEmpty()
Set<K>
keySet()
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
Slow since this loops.V
remove(Object key)
int
size()
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:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in 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.
-
-