Package jadex.collection
Class BiHashMap<K,V>
java.lang.Object
jadex.collection.BiHashMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
A bidirectional hash map. Note using this implies a bijection (1:1 relation).
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the map.boolean
containsKey
(Object key) Returns whether the forward map contains the specified key.boolean
containsValue
(Object value) Returns whether the reverse map contains the specified key.entrySet()
Returns the entry set of the forward map.flip()
Returns a flipped map, sharing the data with the original map.Returns the value of the key from the forward map.boolean
isEmpty()
Tests if the map is empty.keySet()
Returns the keys of the forward map.Puts an entry into the map, forward direction.void
Puts all entries of a map into this map, forward direction.Removes an entry, forward direction.Returns the entry set of the reverse map.Returns the value of the key from the reverse map.void
Puts all entries of a map into this map, reverse direction.Removes an entry, reverse direction.int
size()
Returns the size of the map.values()
Returns the keys of the reverse map.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
-
Field Details
-
forward
The forward map. -
reverse
The reverse map.
-
-
Constructor Details
-
BiHashMap
public BiHashMap() -
BiHashMap
-
-
Method Details
-
clear
public void clear()Clears the map. -
containsKey
Returns whether the forward map contains the specified key.- Specified by:
containsKey
in interfaceMap<K,
V> - Parameters:
key
- The key.- Returns:
- True, if the forward map contains key.
-
containsValue
Returns whether the reverse map contains the specified key.- Specified by:
containsValue
in interfaceMap<K,
V> - Parameters:
key
- The key.- Returns:
- True, if the reverse map contains key.
-
entrySet
Returns the entry set of the forward map. -
rentrySet
Returns the entry set of the reverse map.- Returns:
- The entry set of the reverse map.
-
get
Returns the value of the key from the forward map. -
rget
Returns the value of the key from the reverse map.- Returns:
- The value.
-
isEmpty
public boolean isEmpty()Tests if the map is empty. -
keySet
Returns the keys of the forward map. -
put
Puts an entry into the map, forward direction. -
size
public int size()Returns the size of the map. -
remove
Removes an entry, forward direction. -
rremove
Removes an entry, reverse direction.- Parameters:
key
- The entry key.- Returns:
- The removed value.
-
putAll
Puts all entries of a map into this map, forward direction. -
rputAll
Puts all entries of a map into this map, reverse direction.- Parameters:
m
- The map.
-
values
Returns the keys of the reverse map. -
flip
Returns a flipped map, sharing the data with the original map.- Returns:
- Map with keys and values reversed.
-