BidiMap to ensure it can't be altered.
Attempts to modify it will result in an UnsupportedOperationException.
| Modifier and Type | Field and Description |
|---|---|
| private UnmodifiableBidiMap | inverse
The inverse unmodifiable map |
| Access | Constructor and Description |
|---|---|
| private | UnmodifiableBidiMap(final BidiMap<? extends K, ? extends V>
the map to decorate, must not be null map)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides org. Implements java. |
| public Set | entrySet()
Overrides org. Implements java. Set view of the mappings contained in this map.
|
| public synchronized BidiMap | inverseBidiMap()
Overrides org. Implements org. |
| public Set | keySet()
Overrides org. Implements java. Set view of the keys contained in this map.
|
| public MapIterator | mapIterator()
Overrides org. Implements org. MapIterator over the map.
|
| public V | put(final K
the key to store key, final V the value to store value)Overrides org. Implements org. |
| public void | putAll(final Map<? extends K, ? extends V>
mappings to be stored in this map mapToCopy)Overrides org. Implements java. |
| public V | remove(final Object
key whose mapping is to be removed from the map key)Overrides org. Implements java. |
| public K | removeValue(final Object
the value to find the key-value pair for value)Overrides org. Implements org. |
| public static < the key type K, the value type V> BidiMap | Returns: an unmodifiable BidiMapthe map to decorate, must not be null map)Factory method to create an unmodifiable map. |
| public Set | values()
Overrides org. Implements org. Set view of the values contained in this map.
|
| inverse | back to summary |
|---|---|
| private UnmodifiableBidiMap<V, K> inverse The inverse unmodifiable map | |
| UnmodifiableBidiMap | back to summary |
|---|---|
| private UnmodifiableBidiMap(final BidiMap<? extends K, ? extends V> map) Constructor that wraps (not copies).
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| entrySet | back to summary |
|---|---|
| public Set Overrides org. Implements java. Doc from java. Returns a | |
| inverseBidiMap | back to summary |
|---|---|
| public synchronized BidiMap Overrides org. Implements org. Doc from org. Gets a view of this map where the keys and values are reversed.
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
Implementations should seek to avoid creating a new object every time this
method is called. See | |
| keySet | back to summary |
|---|---|
| public Set Overrides org. Implements java. Doc from java. Returns a | |
| mapIterator | back to summary |
|---|---|
| public MapIterator Overrides org. Implements org. Doc from org. Obtains a 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);
}
| |
| put | back to summary |
|---|---|
| public V put(final K key, final V value) Overrides org. Implements org. Doc from org. Puts the key-value pair into the map, replacing any previous pair. When adding a key-value pair, the value may already exist in the map against a different key. That mapping is removed, to ensure that the value only occurs once in the inverse map.
BidiMap map1 = new DualHashBidiMap();
map.put("A","B"); // contains A mapped to B, as per Map
map.put("A","C"); // contains A mapped to C, as per Map
BidiMap map2 = new DualHashBidiMap();
map.put("A","B"); // contains A mapped to B, as per Map
map.put("C","B"); // contains C mapped to B, key A is removed
| |
| putAll | back to summary |
|---|---|
| public void putAll(final Map<? extends K, ? extends V> mapToCopy) Overrides org. Implements java. Doc from java. Copies all of the mappings from the specified map to this map
(optional operation). The effect of this call is equivalent to that
of calling | |
| remove | back to summary |
|---|---|
| public V remove(final Object key) Overrides org. Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns. | |
| removeValue | back to summary |
|---|---|
| public K removeValue(final Object value) Overrides org. Implements org. Doc from org. Removes the key-value pair that is currently mapped to the specified value (optional operation).
If the value is not contained in the map,
Implementations should seek to make this method perform equally as well
as | |
| unmodifiableBidiMap | back to summary |
|---|---|
| public static <K, V> BidiMap Factory method to create an unmodifiable map. If the map passed in is already unmodifiable, it is returned.
| |
| values | back to summary |
|---|---|
| public Set Overrides org. Implements org. Doc from org. Returns a | |