Package jadex.commons.collection
Class BiHashMap<K,V>
- java.lang.Object
-
- jadex.commons.collection.BiHashMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
public class BiHashMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
A bidirectional hash map. Note using this implies a bijection (1:1 relation).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the map.boolean
containsKey(java.lang.Object key)
Returns whether the forward map contains the specified key.boolean
containsValue(java.lang.Object value)
Returns whether the reverse map contains the specified key.java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
Returns the entry set of the forward map.BiHashMap<V,K>
flip()
Returns a flipped map, sharing the data with the original map.V
get(java.lang.Object key)
Returns the value of the key from the forward map.boolean
isEmpty()
Tests if the map is empty.java.util.Set<K>
keySet()
Returns the keys of the forward map.V
put(K key, V value)
Puts an entry into the map, forward direction.void
putAll(java.util.Map<? extends K,? extends V> m)
Puts all entries of a map into this map, forward direction.V
remove(java.lang.Object key)
Removes an entry, forward direction.java.util.Set<java.util.Map.Entry<V,K>>
rentrySet()
Returns the entry set of the reverse map.K
rget(java.lang.Object key)
Returns the value of the key from the reverse map.void
rputAll(java.util.Map<? extends V,? extends K> m)
Puts all entries of a map into this map, reverse direction.K
rremove(java.lang.Object key)
Removes an entry, reverse direction.int
size()
Returns the size of the map.java.util.Collection<V>
values()
Returns the keys of the reverse map.
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
Returns whether the forward map contains the specified key.
-
containsValue
public boolean containsValue(java.lang.Object value)
Returns whether the reverse map contains the specified key.
-
entrySet
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Returns the entry set of the forward map.
-
rentrySet
public java.util.Set<java.util.Map.Entry<V,K>> rentrySet()
Returns the entry set of the reverse map.- Returns:
- The entry set of the reverse map.
-
get
public V get(java.lang.Object key)
Returns the value of the key from the forward map.
-
rget
public K rget(java.lang.Object key)
Returns the value of the key from the reverse map.- Returns:
- The value.
-
isEmpty
public boolean isEmpty()
Tests if the map is empty.
-
keySet
public java.util.Set<K> keySet()
Returns the keys of the forward map.
-
size
public int size()
Returns the size of the map.
-
remove
public V remove(java.lang.Object key)
Removes an entry, forward direction.
-
rremove
public K rremove(java.lang.Object key)
Removes an entry, reverse direction.- Parameters:
key
- The entry key.- Returns:
- The removed value.
-
putAll
public void putAll(java.util.Map<? extends K,? extends V> m)
Puts all entries of a map into this map, forward direction.
-
rputAll
public void rputAll(java.util.Map<? extends V,? extends K> m)
Puts all entries of a map into this map, reverse direction.- Parameters:
m
- The map.
-
values
public java.util.Collection<V> values()
Returns the keys of the reverse map.
-
-