K
- the type of the keys in this mapV
- the type of the values in this mappublic abstract class AbstractBidiMapDecorator<K,V> extends AbstractMapDecorator<K,V> implements BidiMap<K,V>
Methods are forwarded directly to the decorated map.
This implementation does not perform any special processing with the map views. Instead it simply returns the set/collection from the wrapped map. This may be undesirable, for example if you are trying to write a validating implementation it would provide a loophole around the validation. But, you might want that loophole, so this class is kept simple.
Modifier and Type | Method and Description |
---|---|
K |
getKey(java.lang.Object value)
Gets the key that is currently mapped to the specified value.
|
BidiMap<V,K> |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed.
|
MapIterator<K,V> |
mapIterator()
Obtains a
MapIterator over the map. |
K |
removeValue(java.lang.Object value)
Removes the key-value pair that is currently mapped to the specified
value (optional operation).
|
java.util.Set<V> |
values()
Returns a
Set view of the values contained in this map. |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size
containsKey, containsValue, entrySet, get, isEmpty, keySet, remove, size
public MapIterator<K,V> mapIterator()
AbstractIterableMap
MapIterator
over the map.
A map iterator is an efficient way of iterating over maps. There is no need to access the entry set or use Map Entry objects.
IterableMap<String,Integer> map = new HashedMap<String,Integer>(); MapIterator<String,Integer> it = map.mapIterator(); while (it.hasNext()) { String key = it.next(); Integer value = it.getValue(); it.setValue(value + 1); }
mapIterator
in interface IterableGet<K,V>
mapIterator
in class AbstractIterableMap<K,V>
public K getKey(java.lang.Object value)
BidiMap
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as get(Object)
.
public K removeValue(java.lang.Object value)
BidiMap
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as remove(Object)
.
removeValue
in interface BidiMap<K,V>
value
- the value to find the key-value pair fornull
if nothing removedpublic BidiMap<V,K> inverseBidiMap()
BidiMap
Changes to one map will be visible in the other and vice versa.
This enables both directions of the map to be accessed as a Map
.
Implementations should seek to avoid creating a new object every time this
method is called. See AbstractMap.values()
etc. Calling this
method on the inverse map should return the original.
inverseBidiMap
in interface BidiMap<K,V>
public java.util.Set<V> values()
BidiMap
Set
view of the values contained in this map.
The set is backed by the map, so changes to the map are reflected
in the set, and vice-versa. If the map is modified while an iteration
over the set is in progress (except through the iterator's own
remove
operation), the results of the iteration are undefined.
The set supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove
,
Collection.remove
, removeAll
,
retainAll
and clear
operations. It does not
support the add
or addAll
operations.Copyright © 2010 - 2023 Adobe. All Rights Reserved