public final class UnmodifiableSortedBidiMap extends AbstractSortedBidiMapDecorator implements Unmodifiable
SortedBidiMap
to ensure it can't be altered.Modifier and Type | Method and Description |
---|---|
void |
clear() |
static SortedBidiMap |
decorate(SortedBidiMap map)
Factory method to create an unmodifiable map.
|
java.util.Set |
entrySet() |
java.util.SortedMap |
headMap(java.lang.Object toKey) |
BidiMap |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed.
|
OrderedBidiMap |
inverseOrderedBidiMap()
Gets a view of this map where the keys and values are reversed.
|
SortedBidiMap |
inverseSortedBidiMap()
Gets a view of this map where the keys and values are reversed.
|
java.util.Set |
keySet() |
MapIterator |
mapIterator()
Obtains a
MapIterator over the map. |
OrderedMapIterator |
orderedMapIterator()
Obtains an
OrderedMapIterator over the map. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Puts the key-value pair into the map, replacing any previous pair.
|
void |
putAll(java.util.Map mapToCopy) |
java.lang.Object |
remove(java.lang.Object key) |
java.lang.Object |
removeValue(java.lang.Object value)
Removes the key-value pair that is currently mapped to the specified
value (optional operation).
|
java.util.SortedMap |
subMap(java.lang.Object fromKey,
java.lang.Object toKey) |
java.util.SortedMap |
tailMap(java.lang.Object fromKey) |
java.util.Collection |
values() |
comparator
firstKey, lastKey, nextKey, previousKey
getKey
containsKey, containsValue, equals, get, hashCode, isEmpty, size, toString
firstKey, lastKey, nextKey, previousKey
public static SortedBidiMap decorate(SortedBidiMap map)
If the map passed in is already unmodifiable, it is returned.
map
- the map to decorate, must not be nulljava.lang.IllegalArgumentException
- if map is nullpublic void clear()
clear
in interface java.util.Map
clear
in class AbstractMapDecorator
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
BidiMap
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
put
in interface java.util.Map
put
in interface BidiMap
put
in class AbstractMapDecorator
key
- the key to storevalue
- the value to storepublic void putAll(java.util.Map mapToCopy)
putAll
in interface java.util.Map
putAll
in class AbstractMapDecorator
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
remove
in class AbstractMapDecorator
public java.util.Set entrySet()
entrySet
in interface java.util.Map
entrySet
in interface java.util.SortedMap
entrySet
in class AbstractMapDecorator
public java.util.Set keySet()
keySet
in interface java.util.Map
keySet
in interface java.util.SortedMap
keySet
in class AbstractMapDecorator
public java.util.Collection values()
values
in interface java.util.Map
values
in interface java.util.SortedMap
values
in class AbstractMapDecorator
public java.lang.Object 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
removeValue
in class AbstractBidiMapDecorator
value
- the value to find the key-value pair fornull
if nothing removedpublic MapIterator mapIterator()
BidiMap
MapIterator
over the map.
A map iterator is an efficient way of iterating over maps. It does not require that the map is stored using Map Entry objects which can increase performance.
BidiMap map = new DualHashBidiMap(); MapIterator it = map.mapIterator(); while (it.hasNext()) { Object key = it.next(); Object value = it.getValue(); it.setValue("newValue"); }
mapIterator
in interface BidiMap
mapIterator
in interface IterableMap
mapIterator
in class AbstractBidiMapDecorator
public BidiMap 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
inverseBidiMap
in interface OrderedBidiMap
inverseBidiMap
in interface SortedBidiMap
inverseBidiMap
in class AbstractBidiMapDecorator
public OrderedMapIterator orderedMapIterator()
OrderedMap
OrderedMapIterator
over the map.
A ordered map iterator is an efficient way of iterating over maps in both directions.
BidiMap map = new TreeBidiMap(); MapIterator it = map.mapIterator(); while (it.hasNext()) { Object key = it.next(); Object value = it.getValue(); it.setValue("newValue"); Object previousKey = it.previous(); }
orderedMapIterator
in interface OrderedMap
orderedMapIterator
in class AbstractOrderedBidiMapDecorator
public OrderedBidiMap inverseOrderedBidiMap()
OrderedBidiMap
Changes to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed equally.
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.
inverseOrderedBidiMap
in interface OrderedBidiMap
inverseOrderedBidiMap
in class AbstractOrderedBidiMapDecorator
public SortedBidiMap inverseSortedBidiMap()
SortedBidiMap
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 SortedMap
.
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.
The inverse map returned by inverseBidiMap()
should be the
same object as returned by this method.
inverseSortedBidiMap
in interface SortedBidiMap
inverseSortedBidiMap
in class AbstractSortedBidiMapDecorator
public java.util.SortedMap subMap(java.lang.Object fromKey, java.lang.Object toKey)
subMap
in interface java.util.SortedMap
subMap
in class AbstractSortedBidiMapDecorator
public java.util.SortedMap headMap(java.lang.Object toKey)
headMap
in interface java.util.SortedMap
headMap
in class AbstractSortedBidiMapDecorator
public java.util.SortedMap tailMap(java.lang.Object fromKey)
tailMap
in interface java.util.SortedMap
tailMap
in class AbstractSortedBidiMapDecorator
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"