Top Description Fields Constructors Methods
org.apache.commons.collections4.bidimap

public final Class UnmodifiableSortedBidiMap<K, V>

extends AbstractSortedBidiMapDecorator<K, V>
implements Unmodifiable
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.Unmodifiable
Type Parameters
<K>
the type of the keys in this map
<V>
the type of the values in this map
Imports
java.util.Map, .Set, .SortedMap, org.apache.commons.collections4.OrderedMapIterator, .SortedBidiMap, .Unmodifiable, org.apache.commons.collections4.iterators.UnmodifiableOrderedMapIterator, org.apache.commons.collections4.map.UnmodifiableEntrySet, .UnmodifiableSortedMap, org.apache.commons.collections4.set.UnmodifiableSet

Decorates another SortedBidiMap to ensure it can't be altered.

Attempts to modify it will result in an UnsupportedOperationException.

Since
3.0

Field Summary

Modifier and TypeField and Description
private UnmodifiableSortedBidiMap<V, K>
inverse

The inverse unmodifiable map

Constructor Summary

AccessConstructor and Description
private
UnmodifiableSortedBidiMap(final SortedBidiMap<K, ? extends V>
the map to decorate, must not be null
map
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.clear.

Implements java.util.Map.clear, org.apache.commons.collections4.Put.clear.

Removes all of the mappings from this map (optional operation).
public Set<Map.Entry<K, V>>
public SortedMap<K, V>
headMap(final K
high endpoint (exclusive) of the keys in the returned map
toKey
)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.headMap.

Implements java.util.SortedMap.headMap.

Returns a view of the portion of this map whose keys are strictly less than toKey.
public SortedBidiMap<V, K>
public Set<K>
public OrderedMapIterator<K, V>
public V
put(final K
the key to store
key
,
final V
the value to store
value
)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.put.

Implements org.apache.commons.collections4.BidiMap.put, java.util.Map.put, org.apache.commons.collections4.Put.put.

Puts the key-value pair into the map, replacing any previous pair.
public void
putAll(final Map<? extends K, ? extends V>
mappings to be stored in this map
mapToCopy
)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.putAll.

Implements java.util.Map.putAll, org.apache.commons.collections4.Put.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
public V
remove(final Object
key whose mapping is to be removed from the map
key
)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.remove.

Implements java.util.Map.remove, org.apache.commons.collections4.Get.remove.

Removes the mapping for a key from this map if it is present (optional operation).
public K
removeValue(final Object
the value to find the key-value pair for
value
)

Overrides org.apache.commons.collections4.bidimap.AbstractBidiMapDecorator.removeValue.

Implements org.apache.commons.collections4.BidiMap.removeValue.

Removes the key-value pair that is currently mapped to the specified value (optional operation).
public SortedMap<K, V>
subMap(final K
low endpoint (inclusive) of the keys in the returned map
fromKey
,
final K
high endpoint (exclusive) of the keys in the returned map
toKey
)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.subMap.

Implements java.util.SortedMap.subMap.

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
public SortedMap<K, V>
tailMap(final K
low endpoint (inclusive) of the keys in the returned map
fromKey
)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.tailMap.

Implements java.util.SortedMap.tailMap.

Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
public static <
the key type
K
,
the value type
V
>
SortedBidiMap<K, V>

Returns:

an unmodifiable SortedBidiMap
unmodifiableSortedBidiMap
(final SortedBidiMap<K, ? extends V>
the map to decorate, must not be null
map
)

Factory method to create an unmodifiable map.

public Set<V>
Inherited from org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator:
comparatordecoratedvalueComparator

Field Detail

inverseback to summary
private UnmodifiableSortedBidiMap<V, K> inverse

The inverse unmodifiable map

Constructor Detail

UnmodifiableSortedBidiMapback to summary
private UnmodifiableSortedBidiMap(final SortedBidiMap<K, ? extends V> map)

Constructor that wraps (not copies).

Parameters
map:SortedBidiMap<K, ? extends V>

the map to decorate, must not be null

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if map is null

Method Detail

clearback to summary
public void clear()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.clear.

Implements java.util.Map.clear, org.apache.commons.collections4.Put.clear.

Doc from java.util.Map.clear.

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.entrySet.

Implements java.util.Map.entrySet, org.apache.commons.collections4.Get.entrySet, java.util.SortedMap.entrySet.

Doc from java.util.SortedMap.entrySet.

Returns a Set view of the mappings contained in this map. The set's iterator returns the entries in ascending key order. 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, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<K, V>>

a set view of the mappings contained in this map, sorted in ascending key order

Annotations
@Override
headMapback to summary
public SortedMap<K, V> headMap(final K toKey)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.headMap.

Implements java.util.SortedMap.headMap.

Doc from java.util.SortedMap.headMap.

Returns a view of the portion of this map whose keys are strictly less than toKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
toKey:K

high endpoint (exclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys are strictly less than toKey

Annotations
@Override
inverseBidiMapback to summary
public SortedBidiMap<V, K> inverseBidiMap()

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.inverseBidiMap.

Implements org.apache.commons.collections4.SortedBidiMap.inverseBidiMap, org.apache.commons.collections4.OrderedBidiMap.inverseBidiMap, org.apache.commons.collections4.BidiMap.inverseBidiMap.

Doc from org.apache.commons.collections4.SortedBidiMap.inverseBidiMap.

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 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.

Implementations must return a SortedBidiMap instance, usually by forwarding to inverseSortedBidiMap().

Returns:SortedBidiMap<V, K>

an inverted bidirectional map

Annotations
@Override
keySetback to summary
public Set<K> keySet()

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.keySet.

Implements java.util.Map.keySet, org.apache.commons.collections4.Get.keySet, java.util.SortedMap.keySet.

Doc from java.util.SortedMap.keySet.

Returns a Set view of the keys contained in this map. The set's iterator returns the keys in ascending order. 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, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Returns:Set<K>

a set view of the keys contained in this map, sorted in ascending order

Annotations
@Override
mapIteratorback to summary
public OrderedMapIterator<K, V> mapIterator()

Overrides org.apache.commons.collections4.bidimap.AbstractOrderedBidiMapDecorator.mapIterator.

Implements org.apache.commons.collections4.IterableGet.mapIterator, org.apache.commons.collections4.OrderedMap.mapIterator.

Doc from org.apache.commons.collections4.OrderedMap.mapIterator.

Obtains an OrderedMapIterator over the map.

A ordered map iterator is an efficient way of iterating over maps in both directions.

Returns:OrderedMapIterator<K, V>

a map iterator

Annotations
@Override
putback to summary
public V put(final K key, final V value)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.put.

Implements org.apache.commons.collections4.BidiMap.put, java.util.Map.put, org.apache.commons.collections4.Put.put.

Doc from org.apache.commons.collections4.BidiMap.put.

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
Parameters
key:K

the key to store

value:V

the value to store

Returns:V

the previous value mapped to this key

Annotations
@Override
putAllback to summary
public void putAll(final Map<? extends K, ? extends V> mapToCopy)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.putAll.

Implements java.util.Map.putAll, org.apache.commons.collections4.Put.putAll.

Doc from java.util.Map.putAll.

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 put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress. If the specified map has a defined encounter order, processing of its mappings generally occurs in that order.

Parameters
mapToCopy:Map<? extends K, ? extends V>

mappings to be stored in this map

Annotations
@Override
removeback to summary
public V remove(final Object key)

Overrides org.apache.commons.collections4.map.AbstractMapDecorator.remove.

Implements java.util.Map.remove, org.apache.commons.collections4.Get.remove.

Doc from java.util.Map.remove.

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 k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
key:Object

key whose mapping is to be removed from the map

Returns:V

the previous value associated with key, or null if there was no mapping for key.

Annotations
@Override
removeValueback to summary
public K removeValue(final Object value)

Overrides org.apache.commons.collections4.bidimap.AbstractBidiMapDecorator.removeValue.

Implements org.apache.commons.collections4.BidiMap.removeValue.

Doc from org.apache.commons.collections4.BidiMap.removeValue.

Removes the key-value pair that is currently mapped to the specified value (optional operation).

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).

Parameters
value:Object

the value to find the key-value pair for

Returns:K

the key that was removed, null if nothing removed

Annotations
@Override
subMapback to summary
public SortedMap<K, V> subMap(final K fromKey, final K toKey)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.subMap.

Implements java.util.SortedMap.subMap.

Doc from java.util.SortedMap.subMap.

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned map is empty.) The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
fromKey:K

low endpoint (inclusive) of the keys in the returned map

toKey:K

high endpoint (exclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive

Annotations
@Override
tailMapback to summary
public SortedMap<K, V> tailMap(final K fromKey)

Overrides org.apache.commons.collections4.bidimap.AbstractSortedBidiMapDecorator.tailMap.

Implements java.util.SortedMap.tailMap.

Doc from java.util.SortedMap.tailMap.

Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa. The returned map supports all optional map operations that this map supports.

The returned map will throw an IllegalArgumentException on an attempt to insert a key outside its range.

Parameters
fromKey:K

low endpoint (inclusive) of the keys in the returned map

Returns:SortedMap<K, V>

a view of the portion of this map whose keys are greater than or equal to fromKey

Annotations
@Override
unmodifiableSortedBidiMapback to summary
public static <K, V> SortedBidiMap<K, V> unmodifiableSortedBidiMap(final SortedBidiMap<K, ? extends V> map)

Factory method to create an unmodifiable map.

If the map passed in is already unmodifiable, it is returned.

Parameters
<K>
the key type
<V>
the value type
map:SortedBidiMap<K, ? extends V>

the map to decorate, must not be null

Returns:SortedBidiMap<K, V>

an unmodifiable SortedBidiMap

Exceptions
NullPointerException:
if map is null
Since
4.0
valuesback to summary
public Set<V> values()

Overrides org.apache.commons.collections4.bidimap.AbstractBidiMapDecorator.values.

Implements org.apache.commons.collections4.BidiMap.values, java.util.Map.values, org.apache.commons.collections4.Get.values, java.util.SortedMap.values.

Doc from java.util.SortedMap.values.

Returns a Collection view of the values contained in this map. The collection's iterator returns the values in ascending order of the corresponding keys. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection 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.

Returns:Set<V>

a collection view of the values contained in this map, sorted in ascending key order

Annotations
@Override