Class BiMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.onemind.commons.java.datastructure.BiMap
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map
public class BiMap extends java.util.HashMapA simple bi-directional map. It uses another map to store the inverse of this map. The key has to be unique in key space and the value need to be unique in the value space so that the value can be resolved to the key correctly. This class is not thread safe.- Version:
- $Id: BiMap.java,v 1.1 2004/09/29 02:45:35 thlee Exp $ $Name: $
- Author:
- TiongHiang Lee (thlee@onemindsoft.org)
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()BiMapgetInverse()Get the inverse bimapjava.lang.Objectput(java.lang.Object key, java.lang.Object value)private java.lang.ObjectrawPut(java.lang.Object key, java.lang.Object value)Put the key value association with super.put()private java.lang.ObjectrawRemove(java.lang.Object key)Remove the keyjava.lang.Objectremove(java.lang.Object key)-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
_inverse
private final BiMap _inverse
the inverse
-
-
Constructor Detail
-
BiMap
public BiMap()
Constructor
-
BiMap
private BiMap(BiMap inverse)
Constructor- Parameters:
map- the inverse
-
-
Method Detail
-
getInverse
public BiMap getInverse()
Get the inverse bimap- Returns:
- the bimap
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map- Overrides:
clearin classjava.util.HashMap
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)- Specified by:
putin interfacejava.util.Map- Overrides:
putin classjava.util.HashMap
-
rawPut
private java.lang.Object rawPut(java.lang.Object key, java.lang.Object value)Put the key value association with super.put()- Parameters:
key- the keyvalue- the value
-
rawRemove
private java.lang.Object rawRemove(java.lang.Object key)
Remove the key- Parameters:
key- the key- Returns:
- the value by super.remove();
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map- Overrides:
removein classjava.util.HashMap
-
-