public class DualTreeBidiMap extends AbstractDualBidiMap implements SortedBidiMap, Serializable
BidiMap
that uses two TreeMap
instances.
The setValue() method on iterators will succeed only if the new value being set is not already in the bidimap.
When considering whether to use this class, the TreeBidiMap
class should
also be considered. It implements the interface using a dedicated design, and does
not store each object twice, which can save on memory use.
NOTE: From Commons Collections 3.1, all subclasses will use TreeMap
and the flawed createMap
method is ignored.
Modifier and Type | Class and Description |
---|---|
protected static class |
DualTreeBidiMap.BidiOrderedMapIterator
Inner class MapIterator.
|
protected static class |
DualTreeBidiMap.ViewMap
Internal sorted map view.
|
AbstractDualBidiMap.BidiMapIterator, AbstractDualBidiMap.EntrySet, AbstractDualBidiMap.EntrySetIterator, AbstractDualBidiMap.KeySet, AbstractDualBidiMap.KeySetIterator, AbstractDualBidiMap.MapEntry, AbstractDualBidiMap.Values, AbstractDualBidiMap.ValuesIterator, AbstractDualBidiMap.View
Modifier and Type | Field and Description |
---|---|
protected Comparator |
comparator
The comparator to use
|
entrySet, inverseBidiMap, keySet, maps, values
Modifier | Constructor and Description |
---|---|
|
DualTreeBidiMap()
Creates an empty
DualTreeBidiMap |
|
DualTreeBidiMap(Comparator comparator)
Constructs a
DualTreeBidiMap using the specified Comparator. |
|
DualTreeBidiMap(Map map)
Constructs a
DualTreeBidiMap and copies the mappings from
specified Map . |
protected |
DualTreeBidiMap(Map normalMap,
Map reverseMap,
BidiMap inverseBidiMap)
Constructs a
DualTreeBidiMap that decorates the specified maps. |
Modifier and Type | Method and Description |
---|---|
Comparator |
comparator() |
protected BidiMap |
createBidiMap(Map normalMap,
Map reverseMap,
BidiMap inverseMap)
Creates a new instance of this object.
|
Object |
firstKey()
Gets the first key currently in this map.
|
SortedMap |
headMap(Object toKey) |
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.
|
Object |
lastKey()
Gets the last key currently in this map.
|
Object |
nextKey(Object key)
Gets the next key after the one specified.
|
OrderedMapIterator |
orderedMapIterator()
Obtains an ordered map iterator.
|
Object |
previousKey(Object key)
Gets the previous key before the one specified.
|
SortedMap |
subMap(Object fromKey,
Object toKey) |
SortedMap |
tailMap(Object fromKey) |
clear, containsKey, containsValue, createEntrySetIterator, createKeySetIterator, createMap, createValuesIterator, entrySet, equals, get, getKey, hashCode, inverseBidiMap, isEmpty, keySet, mapIterator, put, putAll, remove, removeValue, size, toString, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
inverseBidiMap
getKey, mapIterator, put, removeValue
protected final Comparator comparator
public DualTreeBidiMap()
DualTreeBidiMap
public DualTreeBidiMap(Map map)
DualTreeBidiMap
and copies the mappings from
specified Map
.map
- the map whose mappings are to be placed in this mappublic DualTreeBidiMap(Comparator comparator)
DualTreeBidiMap
using the specified Comparator.comparator
- the Comparatorprotected BidiMap createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseMap)
createBidiMap
in class AbstractDualBidiMap
normalMap
- the normal direction mapreverseMap
- the reverse direction mapinverseMap
- the inverse BidiMappublic Comparator comparator()
comparator
in interface SortedMap
public Object firstKey()
OrderedMap
firstKey
in interface SortedMap
firstKey
in interface OrderedMap
public Object lastKey()
OrderedMap
lastKey
in interface SortedMap
lastKey
in interface OrderedMap
public Object nextKey(Object key)
OrderedMap
nextKey
in interface OrderedMap
key
- the key to search for next frompublic Object previousKey(Object key)
OrderedMap
previousKey
in interface OrderedMap
key
- the key to search for previous frompublic OrderedMapIterator orderedMapIterator()
This implementation copies the elements to an ArrayList in order to provide the forward/backward behaviour.
orderedMapIterator
in interface OrderedMap
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
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
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.