⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.bidimap

Class DualTreeBidiMap

java.lang.Object
|
+--org.apache.commons.collections.bidimap.AbstractDualBidiMap
   |
   +--org.apache.commons.collections.bidimap.DualTreeBidiMap

All Implemented Interfaces:
BidiMap, SortedBidiMap, Serializable


public class DualTreeBidiMap
extends AbstractDualBidiMap
implements SortedBidiMap, Serializable

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.

Since:
Commons Collections 3.0
Authors:
Matthew Hawthorne
Stephen Colebourne

Field Summary

Comparator

comparator

The comparator to use

Constructor Summary

DualTreeBidiMap()

Creates an empty DualTreeBidiMap

DualTreeBidiMap(Map map)

Constructs a DualTreeBidiMap and copies the mappings from specified Map.

DualTreeBidiMap(Comparator comparator)

Constructs a DualTreeBidiMap using the specified Comparator.

DualTreeBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap)

Constructs a HashBidiMap that decorates the specified maps.

Method Summary

Comparator

comparator()

BidiMap

createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseMap)

Creates a new instance of this object.

Map

createMap()

Creates a new instance of the map used by the subclass to store data.

Object

firstKey()

SortedMap

headMap(Object toKey)

OrderedBidiMap

inverseOrderedBidiMap()

SortedBidiMap

inverseSortedBidiMap()

Object

lastKey()

Object

nextKey(Object key)

OrderedMapIterator

orderedMapIterator()

Obtains an ordered map iterator.

Object

previousKey(Object key)

SortedMap

subMap(Object fromKey, Object toKey)

SortedMap

tailMap(Object fromKey)

Field Details

comparator

protected final Comparator comparator

The comparator to use

Constructor Details

DualTreeBidiMap

public DualTreeBidiMap()

Creates an empty DualTreeBidiMap


DualTreeBidiMap

public DualTreeBidiMap(Comparator comparator)

Constructs a DualTreeBidiMap using the specified Comparator.

Parameters:
comparator - the Comparator

DualTreeBidiMap

protected DualTreeBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap)

Constructs a HashBidiMap that decorates the specified maps.

Parameters:
normalMap - the normal direction map
reverseMap - the reverse direction map
inverseBidiMap - the inverse BidiMap

DualTreeBidiMap

public DualTreeBidiMap(Map map)

Constructs a DualTreeBidiMap and copies the mappings from specified Map.

Parameters:
map - the map whose mappings are to be placed in this map

Method Details

comparator

public Comparator comparator()


createBidiMap

protected BidiMap createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseMap)

Creates a new instance of this object.

Parameters:
normalMap - the normal direction map
reverseMap - the reverse direction map
inverseMap - the inverse BidiMap
Returns:
new bidi map

createMap

protected Map createMap()

Creates a new instance of the map used by the subclass to store data.

Returns:
the map to be used for internal storage

firstKey

public Object firstKey()


headMap

public SortedMap headMap(Object toKey)

Parameters:
toKey

inverseOrderedBidiMap

public OrderedBidiMap inverseOrderedBidiMap()


inverseSortedBidiMap

public SortedBidiMap inverseSortedBidiMap()


lastKey

public Object lastKey()


nextKey

public Object nextKey(Object key)

Parameters:
key

orderedMapIterator

public OrderedMapIterator orderedMapIterator()

Obtains an ordered map iterator.

This implementation copies the elements to an ArrayList in order to provide the forward/backward behaviour.


previousKey

public Object previousKey(Object key)

Parameters:
key

subMap

public SortedMap subMap(Object fromKey, Object toKey)

Parameters:
fromKey
toKey

tailMap

public SortedMap tailMap(Object fromKey)

Parameters:
fromKey