|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.bidimap.AbstractDualBidiMap<K,V>
org.apache.commons.collections.bidimap.DualTreeBidiMap<K,V>
public class DualTreeBidiMap<K,V>
Implementation of BidiMap that uses two TreeMap instances.
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<K,V>
Inner class MapIterator. |
protected static class |
DualTreeBidiMap.ViewMap<K,V>
Internal sorted map view. |
| Nested classes/interfaces inherited from class org.apache.commons.collections.bidimap.AbstractDualBidiMap |
|---|
AbstractDualBidiMap.BidiMapIterator<K,V>, AbstractDualBidiMap.EntrySet<K,V>, AbstractDualBidiMap.EntrySetIterator<K,V>, AbstractDualBidiMap.KeySet<K,V>, AbstractDualBidiMap.KeySetIterator<K,V>, AbstractDualBidiMap.MapEntry<K,V>, AbstractDualBidiMap.Values<K,V>, AbstractDualBidiMap.ValuesIterator<K,V>, AbstractDualBidiMap.View<K,V,E> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected Comparator<? super K> |
comparator
The comparator to use |
| Fields inherited from class org.apache.commons.collections.bidimap.AbstractDualBidiMap |
|---|
entrySet, forwardMap, inverseBidiMap, inverseMap, keySet, values |
| Constructor Summary | |
|---|---|
|
DualTreeBidiMap()
Creates an empty DualTreeBidiMap |
|
DualTreeBidiMap(Comparator<? super K> comparator,
Comparator<? super V> inverseComparator)
Constructs a DualTreeBidiMap using the specified Comparators. |
|
DualTreeBidiMap(Map<? extends K,? extends V> map)
Constructs a DualTreeBidiMap and copies the mappings from
specified Map. |
protected |
DualTreeBidiMap(Map<K,V> normalMap,
Map<V,K> reverseMap,
BidiMap<V,K> inverseBidiMap)
Constructs a DualTreeBidiMap that decorates the specified maps. |
| Method Summary | ||
|---|---|---|
Comparator<? super K> |
comparator()
|
|
protected
|
createBidiMap(Map<K,V> normalMap,
Map<V,K> reverseMap,
BidiMap<V,K> inverseMap)
Creates a new instance of this object. |
|
static
|
createTwoWayBidiMap(Comparator<? super E> comparator)
|
|
K |
firstKey()
Gets the first key currently in this map. |
|
SortedMap<K,V> |
headMap(K toKey)
|
|
OrderedBidiMap<V,K> |
inverseOrderedBidiMap()
Gets a view of this map where the keys and values are reversed. |
|
SortedBidiMap<V,K> |
inverseSortedBidiMap()
Gets a view of this map where the keys and values are reversed. |
|
K |
lastKey()
Gets the last key currently in this map. |
|
K |
nextKey(K key)
Gets the next key after the one specified. |
|
OrderedMapIterator<K,V> |
orderedMapIterator()
Obtains an ordered map iterator. |
|
K |
previousKey(K key)
Gets the previous key before the one specified. |
|
SortedMap<K,V> |
subMap(K fromKey,
K toKey)
|
|
SortedMap<K,V> |
tailMap(K 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 Comparator<? super K> comparator
| Constructor Detail |
|---|
public DualTreeBidiMap()
DualTreeBidiMap
public DualTreeBidiMap(Map<? extends K,? extends V> map)
DualTreeBidiMap and copies the mappings from
specified Map.
map - the map whose mappings are to be placed in this map
public DualTreeBidiMap(Comparator<? super K> comparator,
Comparator<? super V> inverseComparator)
DualTreeBidiMap using the specified Comparators.
comparator - the Comparator
protected DualTreeBidiMap(Map<K,V> normalMap,
Map<V,K> reverseMap,
BidiMap<V,K> inverseBidiMap)
DualTreeBidiMap that decorates the specified maps.
normalMap - the normal direction mapreverseMap - the reverse direction mapinverseBidiMap - the inverse BidiMap| Method Detail |
|---|
public static <E> DualTreeBidiMap<E,E> createTwoWayBidiMap(Comparator<? super E> comparator)
protected <K,V> BidiMap<K,V> createBidiMap(Map<K,V> normalMap,
Map<V,K> reverseMap,
BidiMap<V,K> inverseMap)
createBidiMap in class AbstractDualBidiMap<K,V>normalMap - the normal direction mapreverseMap - the reverse direction mapinverseMap - the inverse BidiMap
public Comparator<? super K> comparator()
comparator in interface SortedMap<K,V>public K firstKey()
OrderedMap
firstKey in interface SortedMap<K,V>firstKey in interface OrderedMap<K,V>public K lastKey()
OrderedMap
lastKey in interface SortedMap<K,V>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 from
public K previousKey(K key)
OrderedMap
previousKey in interface OrderedMap<K,V>key - the key to search for previous from
public OrderedMapIterator<K,V> orderedMapIterator()
orderedMapIterator in interface OrderedMap<K,V>public SortedBidiMap<V,K> inverseSortedBidiMap()
SortedBidiMapSortedMap.
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<K,V>public OrderedBidiMap<V,K> inverseOrderedBidiMap()
OrderedBidiMapAbstractMap.values() etc. Calling this
method on the inverse map should return the original.
inverseOrderedBidiMap in interface OrderedBidiMap<K,V>public SortedMap<K,V> headMap(K toKey)
headMap in interface SortedMap<K,V>public SortedMap<K,V> tailMap(K fromKey)
tailMap in interface SortedMap<K,V>
public SortedMap<K,V> subMap(K fromKey,
K toKey)
subMap in interface SortedMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||