K
- The type of keys maintained by this map.V
- The type of mapped values.public abstract class BiMap<K,V> extends DelegateMap<K,V>
key->value
and
value->key
mappings. This implementation utilizes the mechanisms of
the ObservableMap
to guarantee operational symmetry between the
this
map and the reverse()
map. Methods defined in the
Map
interface that result in a mutation to the this
instance
will also result in reflected operations to the reverse()
instance.
This implementation is not synchronized.ObservableMap
,
DelegateMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
protected ObservableSet<Map.Entry<K,V>> |
entrySet |
protected ObservableSet<K> |
keySet |
protected BiMap<V,K> |
reverse |
protected ObservableCollection<V> |
values |
target
Modifier | Constructor and Description |
---|---|
protected |
BiMap()
Creates an empty instance.
|
protected |
BiMap(Map<K,V> forward,
Map<V,K> reverse)
Construct a new bidirectional map with the provided source maps.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
Set<K> |
keySet() |
protected abstract BiMap<V,K> |
newEmptyReverseMap()
Returns a new instance of an empty reverse subclass of
BiMap . |
Map<V,K> |
reverse()
Returns the reverse of this map, maintaining
value->key mappings. |
protected void |
setTarget(Map<K,V> map)
Sets the specified map as the underlying target map of this
BiMap . |
Collection<V> |
values() |
clear, compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, superCompute, superComputeIfAbsent, superComputeIfPresent, superForEach, superGetOrDefault, superMerge, superPutIfAbsent, superRemove, superReplace, superReplace, superReplaceAll, toString
clone
protected volatile ObservableSet<K> keySet
protected volatile ObservableCollection<V> values
protected volatile ObservableSet<Map.Entry<K,V>> entrySet
protected BiMap(Map<K,V> forward, Map<V,K> reverse)
forward
- The forward source map.reverse
- The reverse source map.protected BiMap()
protected void setTarget(Map<K,V> map)
BiMap
.map
- The map to set at the underlying target of this BiMap
.protected abstract BiMap<V,K> newEmptyReverseMap()
BiMap
.BiMap
.public Map<V,K> reverse()
value->key
mappings.
Mutations to the map returned by this method map are reflected in this map.public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class DelegateMap<K,V>
public Collection<V> values()
Copyright © 2020 LibJ. All rights reserved.