|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.bidimap.AbstractDualBidiMap
org.apache.commons.collections.bidimap.DualTreeBidiMap
public class DualTreeBidiMap
Implementation of 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.
| Nested Class Summary | |
|---|---|
protected static class |
DualTreeBidiMap.BidiOrderedMapIterator
Inner class MapIterator. |
protected static class |
DualTreeBidiMap.ViewMap
Internal sorted map view. |
| Nested classes/interfaces inherited from class org.apache.commons.collections.bidimap.AbstractDualBidiMap |
|---|
AbstractDualBidiMap.BidiMapIterator, AbstractDualBidiMap.EntrySet, AbstractDualBidiMap.EntrySetIterator, AbstractDualBidiMap.KeySet, AbstractDualBidiMap.KeySetIterator, AbstractDualBidiMap.MapEntry, AbstractDualBidiMap.Values, AbstractDualBidiMap.ValuesIterator, AbstractDualBidiMap.View |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry |
| Field Summary | |
|---|---|
protected java.util.Comparator |
comparator
The comparator to use |
| Fields inherited from class org.apache.commons.collections.bidimap.AbstractDualBidiMap |
|---|
entrySet, inverseBidiMap, keySet, maps, values |
| Constructor Summary | |
|---|---|
|
DualTreeBidiMap()
Creates an empty DualTreeBidiMap |
|
DualTreeBidiMap(java.util.Comparator comparator)
Constructs a DualTreeBidiMap using the specified Comparator. |
|
DualTreeBidiMap(java.util.Map map)
Constructs a DualTreeBidiMap and copies the mappings from
specified Map. |
protected |
DualTreeBidiMap(java.util.Map normalMap,
java.util.Map reverseMap,
BidiMap inverseBidiMap)
Constructs a DualTreeBidiMap that decorates the specified maps. |
| Method Summary | |
|---|---|
java.util.Comparator |
comparator()
|
protected BidiMap |
createBidiMap(java.util.Map normalMap,
java.util.Map reverseMap,
BidiMap inverseMap)
Creates a new instance of this object. |
java.lang.Object |
firstKey()
Gets the first key currently in this map. |
java.util.SortedMap |
headMap(java.lang.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. |
java.lang.Object |
lastKey()
Gets the last key currently in this map. |
java.lang.Object |
nextKey(java.lang.Object key)
Gets the next key after the one specified. |
OrderedMapIterator |
orderedMapIterator()
Obtains an ordered map iterator. |
java.lang.Object |
previousKey(java.lang.Object key)
Gets the previous key before the one specified. |
java.util.SortedMap |
subMap(java.lang.Object fromKey,
java.lang.Object toKey)
|
java.util.SortedMap |
tailMap(java.lang.Object fromKey)
|
| Methods inherited from class org.apache.commons.collections.bidimap.AbstractDualBidiMap |
|---|
clear, containsKey, containsValue, createEntrySetIterator, createKeySetIterator, createMap, createValuesIterator, entrySet, equals, get, getKey, hashCode, inverseBidiMap, isEmpty, keySet, mapIterator, put, putAll, remove, removeValue, size, toString, values |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.commons.collections.SortedBidiMap |
|---|
inverseBidiMap |
| Methods inherited from interface org.apache.commons.collections.BidiMap |
|---|
getKey, mapIterator, put, removeValue |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values |
| Field Detail |
|---|
protected final java.util.Comparator comparator
| Constructor Detail |
|---|
public DualTreeBidiMap()
DualTreeBidiMap
public DualTreeBidiMap(java.util.Map map)
DualTreeBidiMap and copies the mappings from
specified Map.
map - the map whose mappings are to be placed in this mappublic DualTreeBidiMap(java.util.Comparator comparator)
DualTreeBidiMap using the specified Comparator.
comparator - the Comparator
protected DualTreeBidiMap(java.util.Map normalMap,
java.util.Map reverseMap,
BidiMap inverseBidiMap)
DualTreeBidiMap that decorates the specified maps.
normalMap - the normal direction mapreverseMap - the reverse direction mapinverseBidiMap - the inverse BidiMap| Method Detail |
|---|
protected BidiMap createBidiMap(java.util.Map normalMap,
java.util.Map reverseMap,
BidiMap inverseMap)
createBidiMap in class AbstractDualBidiMapnormalMap - the normal direction mapreverseMap - the reverse direction mapinverseMap - the inverse BidiMap
public java.util.Comparator comparator()
comparator in interface java.util.SortedMappublic java.lang.Object firstKey()
OrderedMap
firstKey in interface java.util.SortedMapfirstKey in interface OrderedMappublic java.lang.Object lastKey()
OrderedMap
lastKey in interface java.util.SortedMaplastKey in interface OrderedMappublic java.lang.Object nextKey(java.lang.Object key)
OrderedMap
nextKey in interface OrderedMapkey - the key to search for next from
public java.lang.Object previousKey(java.lang.Object key)
OrderedMap
previousKey in interface OrderedMapkey - the key to search for previous from
public OrderedMapIterator orderedMapIterator()
This implementation copies the elements to an ArrayList in order to provide the forward/backward behaviour.
orderedMapIterator in interface OrderedMappublic 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 SortedBidiMappublic OrderedBidiMap inverseOrderedBidiMap()
OrderedBidiMapChanges 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 OrderedBidiMappublic java.util.SortedMap headMap(java.lang.Object toKey)
headMap in interface java.util.SortedMappublic java.util.SortedMap tailMap(java.lang.Object fromKey)
tailMap in interface java.util.SortedMap
public java.util.SortedMap subMap(java.lang.Object fromKey,
java.lang.Object toKey)
subMap in interface java.util.SortedMap
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||