public abstract class AbstractOrderedBidiMapDecorator<K,V> extends AbstractBidiMapDecorator<K,V> implements OrderedBidiMap<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 inverse 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 | Constructor and Description |
---|---|
protected |
AbstractOrderedBidiMapDecorator(OrderedBidiMap<K,V> map)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
protected OrderedBidiMap<K,V> |
decorated()
Gets the map being decorated.
|
K |
firstKey()
Gets the first key currently in this map.
|
OrderedBidiMap<V,K> |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed.
|
K |
lastKey()
Gets the last key currently in this map.
|
OrderedMapIterator<K,V> |
mapIterator()
Obtains a
MapIterator over the map. |
K |
nextKey(K key)
Gets the next key after the one specified.
|
K |
previousKey(K key)
Gets the previous key before the one specified.
|
getKey, removeValue, values
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getKey, put, removeValue, values
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size
containsKey, containsValue, entrySet, get, isEmpty, keySet, remove, size
protected AbstractOrderedBidiMapDecorator(OrderedBidiMap<K,V> map)
map
- the map to decorate, must not be nullIllegalArgumentException
- if the collection is nullprotected OrderedBidiMap<K,V> decorated()
decorated
in class AbstractBidiMapDecorator<K,V>
public OrderedMapIterator<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.
IterableMapmap = new HashedMap (); MapIterator 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 interface OrderedMap<K,V>
mapIterator
in class AbstractBidiMapDecorator<K,V>
public K firstKey()
OrderedMap
firstKey
in interface OrderedMap<K,V>
public K lastKey()
OrderedMap
lastKey
in interface OrderedMap<K,V>
public K nextKey(K key)
OrderedMap
nextKey
in interface OrderedMap<K,V>
key
- the key to search for next frompublic K previousKey(K key)
OrderedMap
previousKey
in interface OrderedMap<K,V>
key
- the key to search for previous frompublic OrderedBidiMap<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>
inverseBidiMap
in interface OrderedBidiMap<K,V>
inverseBidiMap
in class AbstractBidiMapDecorator<K,V>
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.