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 | |
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator | comparator
The key comparator to use |
| private static final long | serialVersionUID
Ensure serialization compatibility |
| private final Comparator | valueComparator
The value comparator to use |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DualTreeBidiMap(final Map<? extends K, ? extends V>
the map whose mappings are to be placed in this map map)Constructs a |
| public | DualTreeBidiMap(final Comparator<? super K>
the comparator keyComparator, final Comparator<? super V> the values comparator to use valueComparator)Constructs a |
| protected | DualTreeBidiMap(final Map<K, V>
the normal direction map normalMap, final Map<V, K> the reverse direction map reverseMap, final BidiMap<V, K> the inverse BidiMap inverseBidiMap)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public Comparator | comparator()
Implements java. null if this map uses the natural ordering of its keys.
|
| protected DualTreeBidiMap | Returns: new bidi mapthe normal direction map normalMap, final Map<K, V> the reverse direction map reverseMap, final BidiMap<K, V> the inverse BidiMap inverseMap)Implements abstract org. |
| public K | firstKey()
Implements org. |
| public SortedMap | headMap(final K
high endpoint (exclusive) of the keys in the returned map toKey)Implements java. toKey.
|
| public SortedBidiMap | inverseBidiMap()
Overrides org. Implements org. |
| public OrderedBidiMap | |
| public SortedBidiMap | |
| public K | lastKey()
Implements org. |
| public OrderedMapIterator | Returns: a new ordered map iteratorOverrides org. Implements org. |
| public K | nextKey(final K
the key to search for next from key)Implements org. |
| public K | previousKey(final K
the key to search for previous from key)Implements org. |
| private void | |
| public SortedMap | 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)Implements java. fromKey, inclusive, to toKey, exclusive.
|
| public SortedMap | tailMap(final K
low endpoint (inclusive) of the keys in the returned map fromKey)Implements java. fromKey.
|
| public Comparator | valueComparator()
Implements org. |
| private void |
| comparator | back to summary |
|---|---|
| private final Comparator<? super K> comparator The key comparator to use | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Ensure serialization compatibility | |
| valueComparator | back to summary |
|---|---|
| private final Comparator<? super V> valueComparator The value comparator to use | |
| DualTreeBidiMap | back to summary |
|---|---|
| public DualTreeBidiMap() Creates an empty | |
| DualTreeBidiMap | back to summary |
|---|---|
| public DualTreeBidiMap(final Map<? extends K, ? extends V> map) Constructs a
| |
| DualTreeBidiMap | back to summary |
|---|---|
| public DualTreeBidiMap(final Comparator<? super K> keyComparator, final Comparator<? super V> valueComparator) Constructs a
| |
| DualTreeBidiMap | back to summary |
|---|---|
| protected DualTreeBidiMap(final Map<K, V> normalMap, final Map<V, K> reverseMap, final BidiMap<V, K> inverseBidiMap) Constructs a | |
| comparator | back to summary |
|---|---|
| public Comparator Implements java. Doc from java. Returns the comparator used to order the keys in this map, or
| |
| createBidiMap | back to summary |
|---|---|
| protected DualTreeBidiMap Implements abstract org. Creates a new instance of this object.
| |
| firstKey | back to summary |
|---|---|
| public K firstKey() Implements org. Doc from java. Returns the first (lowest) key currently in this map.
| |
| headMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an | |
| inverseBidiMap | back to summary |
|---|---|
| public SortedBidiMap Overrides org. Implements org. Doc from org. 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
Implementations must return a
| |
| inverseOrderedBidiMap | back to summary |
|---|---|
| public OrderedBidiMap | |
| inverseSortedBidiMap | back to summary |
|---|---|
| public SortedBidiMap | |
| lastKey | back to summary |
|---|---|
| public K lastKey() Implements org. Doc from java. Returns the last (highest) key currently in this map.
| |
| mapIterator | back to summary |
|---|---|
| public OrderedMapIterator Overrides org. Implements org. Obtains an ordered map iterator. This implementation copies the elements to an ArrayList in order to provide the forward/backward behaviour.
| |
| nextKey | back to summary |
|---|---|
| public K nextKey(final K key) Implements org. Doc from org. Gets the next key after the one specified.
| |
| previousKey | back to summary |
|---|---|
| public K previousKey(final K key) Implements org. Doc from org. Gets the previous key before the one specified.
| |
| readObject | back to summary |
|---|---|
| private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException | |
| subMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an | |
| tailMap | back to summary |
|---|---|
| public SortedMap Implements java. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an | |
| valueComparator | back to summary |
|---|---|
| public Comparator Implements org. Doc from org. Get the comparator used for the values in the value-to-key map aspect.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(final ObjectOutputStream out) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private ListIterator | iterator
The iterator being decorated |
| private Map. | last
The last returned entry |
| private final AbstractDualBidiMap | parent
The parent map |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public K | getKey()
Implements org. next().
|
| public V | getValue()
Implements org. next().
|
| public boolean | hasNext()
Implements org. |
| public boolean | hasPrevious()
Implements org. |
| public K | next()
Implements org. Map.
|
| public K | previous()
Implements org. Map.
|
| public void | remove()
Overrides default java. Implements org. Map (optional operation).
|
| public void | reset()
Implements org. |
| public V | setValue(final V
the new value value)Implements org. |
| public String |
| iterator | back to summary |
|---|---|
| private ListIterator<Map. The iterator being decorated | |
| last | back to summary |
|---|---|
| private Map. The last returned entry | |
| parent | back to summary |
|---|---|
| private final AbstractDualBidiMap<K, V> parent The parent map | |
| BidiOrderedMapIterator | back to summary |
|---|---|
| protected BidiOrderedMapIterator(final AbstractDualBidiMap<K, V> parent) Constructor.
| |
| getKey | back to summary |
|---|---|
| public K getKey() Implements org. Doc from org. Gets the current key, which is the key returned by the last call
to
| |
| getValue | back to summary |
|---|---|
| public V getValue() Implements org. Doc from org. Gets the current value, which is the value associated with the last key
returned by
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements org. Doc from org. Checks to see if there are more entries still to be iterated.
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements org. Doc from org. Checks to see if there is a previous entry that can be iterated to.
| |
| next | back to summary |
|---|---|
| public K next() Implements org. Doc from org. Gets the next key from the
| |
| previous | back to summary |
|---|---|
| public K previous() Implements org. Doc from org. Gets the previous key from the
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Implements org. Doc from org. Removes the last returned key from the underlying
This method can be called once per call to
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Resets the iterator back to the position at which the iterator was created.
| |
| setValue | back to summary |
|---|---|
| public V setValue(final V value) Implements org. Doc from org. Sets the value associated with the current key (optional operation).
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Access | Constructor and Description |
|---|---|
| protected | ViewMap(final DualTreeBidiMap<K, V>
the parent bidi map bidi, final SortedMap<K, V> the subMap sorted map sm)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides org. Implements java. |
| public boolean | containsValue(final Object
value whose presence in this map is to be tested value)Overrides org. Implements java. true if this map maps one or more keys to the
specified value.
|
| protected DualTreeBidiMap | decorated()
Overrides org. |
| public SortedMap | headMap(final K
high endpoint (exclusive) of the keys in the returned map toKey)Overrides org. Implements java. toKey.
|
| public K | nextKey(final K
the key to search for next from key)Overrides org. Implements org. |
| public K | previousKey(final K
the key to search for previous from key)Overrides org. Implements org. |
| public SortedMap | 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. Implements java. fromKey, inclusive, to toKey, exclusive.
|
| public SortedMap | tailMap(final K
low endpoint (inclusive) of the keys in the returned map fromKey)Overrides org. Implements java. fromKey.
|
| ViewMap | back to summary |
|---|---|
| protected ViewMap(final DualTreeBidiMap<K, V> bidi, final SortedMap<K, V> sm) Constructor.
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(final Object value) Overrides org. Implements java. Doc from java. Returns | |
| decorated | back to summary |
|---|---|
| protected DualTreeBidiMap Overrides org. Doc from org. Gets the map being decorated.
| |
| headMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an | |
| nextKey | back to summary |
|---|---|
| public K nextKey(final K key) Overrides org. Implements org. Doc from org. Gets the next key after the one specified.
| |
| previousKey | back to summary |
|---|---|
| public K previousKey(final K key) Overrides org. Implements org. Doc from org. Gets the previous key before the one specified.
| |
| subMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an | |
| tailMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an | |