Package org.eclipse.emf.ecp.common.spi
Class BidirectionalMap<K,V>
- java.lang.Object
-
- org.eclipse.emf.ecp.common.spi.BidirectionalMap<K,V>
-
- Type Parameters:
K- the type of the keyV- the type of the value
public class BidirectionalMap<K,V> extends java.lang.ObjectConvenience class for mapping keys to values and vice versa. Both, keys and values, have to be unique.- Since:
- 1.5
- Author:
- emuller
-
-
Constructor Summary
Constructors Constructor Description BidirectionalMap()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KgetByValue(V value)Returns the key belonging to the given value.VgetValue(K key)Returns the value belonging to the given key.java.util.Set<K>keys()Returns all keys.voidput(K key, V value)Associates the specified value with the specified key in this map and vice versa.VremoveByKey(K key)Removes the bidirectional mapping for the given key.KremoveByValue(V value)Removes the bidirectional mapping for the given value.java.util.Set<V>values()Returns all values.
-
-
-
Method Detail
-
put
public void put(K key, V value)
Associates the specified value with the specified key in this map and vice versa.- Parameters:
key- the keyvalue- the value
-
removeByKey
public V removeByKey(K key)
Removes the bidirectional mapping for the given key.- Parameters:
key- the key to be removed- Returns:
- the value that was associated with the key
-
removeByValue
public K removeByValue(V value)
Removes the bidirectional mapping for the given value.- Parameters:
value- the value to be removed- Returns:
- the key that was associated with the value
-
getValue
public V getValue(K key)
Returns the value belonging to the given key.- Parameters:
key- the key whose value should be looked up- Returns:
- the value belonging to the given key
-
getByValue
public K getByValue(V value)
Returns the key belonging to the given value.- Parameters:
value- the key whose value should be looked up- Returns:
- the key belonging to the given value
-
keys
public java.util.Set<K> keys()
Returns all keys.- Returns:
- a set of all keys
-
values
public java.util.Set<V> values()
Returns all values.- Returns:
- a set of all values
-
-