org.apache.commons.collections.bidimap |
This package contains implementations of the
{@link org.apache.commons.collections.BidiMap BidiMap},
{@link org.apache.commons.collections.OrderedBidiMap OrderedBidiMap} and
{@link org.apache.commons.collections.SortedBidiMap SortedBidiMap} interfaces.
A BidiMap is an extension to Map that allows keys and values to be looked up with equal ease.
One example usage is a system communicating to a legacy datasource that must convert codes
from the new format to the old format and vice versa.
The following implementations are provided in the package:
- DualHashBidiMap - uses two HashMaps to implement BidiMap
- DualTreeBidiMap - uses two TreeMaps to implement SortedBidiMap
- TreeBidiMap - red-black tree implementation of OrderedBidiMap
The following decorators are provided in the package:
- Unmodifiable - ensures the map cannot be altered
|
Java Source File Name | Type | Comment |
AbstractBidiMapDecorator.java | Class | Provides a base decorator that enables additional functionality to be added
to a BidiMap via decoration.
Methods are forwarded directly to the decorated map.
This implementation does not perform any special processing with the map views.
Instead it simply returns the set/collection from the wrapped map. |
AbstractDualBidiMap.java | Class | Abstract BidiMap implemented using two maps. |
AbstractOrderedBidiMapDecorator.java | Class | Provides a base decorator that enables additional functionality to be added
to an OrderedBidiMap via decoration.
Methods are forwarded directly to the decorated map.
This implementation does not perform any special processing with the map views.
Instead it simply returns the inverse from the wrapped map. |
AbstractSortedBidiMapDecorator.java | Class | Provides a base decorator that enables additional functionality to be added
to a SortedBidiMap via decoration.
Methods are forwarded directly to the decorated map.
This implementation does not perform any special processing with the map views.
Instead it simply returns the inverse from the wrapped map. |
AbstractTestBidiMap.java | Class | Abstract test class for
BidiMap methods and contracts. |
AbstractTestOrderedBidiMap.java | Class | Abstract test class for
OrderedBidiMap methods and contracts. |
AbstractTestSortedBidiMap.java | Class | Abstract test class for
SortedBidiMap methods and contracts. |
DualHashBidiMap.java | Class | Implementation of BidiMap that uses two HashMap instances. |
DualTreeBidiMap.java | Class | 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. |
TestAbstractOrderedBidiMapDecorator.java | Class | Test class for AbstractOrderedBidiMapDecorator. |
TestAll.java | Class | Entry point for tests. |
TestDualHashBidiMap.java | Class | JUnit tests. |
TestDualTreeBidiMap.java | Class | JUnit tests. |
TestDualTreeBidiMap2.java | Class | JUnit tests. |
TestTreeBidiMap.java | Class | JUnit tests. |
TestUnmodifiableBidiMap.java | Class | JUnit tests. |
TestUnmodifiableOrderedBidiMap.java | Class | JUnit tests. |
TestUnmodifiableSortedBidiMap.java | Class | JUnit tests. |
TreeBidiMap.java | Class | Red-Black tree-based implementation of BidiMap where all objects added
implement the Comparable interface.
This class guarantees that the map will be in both ascending key order
and ascending value order, sorted according to the natural order for
the key's and value's classes.
This Map is intended for applications that need to be able to look
up a key-value pairing by either key or value, and need to do so
with equal efficiency.
While that goal could be accomplished by taking a pair of TreeMaps
and redirecting requests to the appropriate TreeMap (e.g.,
containsKey would be directed to the TreeMap that maps values to
keys, containsValue would be directed to the TreeMap that maps keys
to values), there are problems with that implementation.
If the data contained in the TreeMaps is large, the cost of redundant
storage becomes significant. |
UnmodifiableBidiMap.java | Class | Decorates another BidiMap to ensure it can't be altered. |
UnmodifiableOrderedBidiMap.java | Class | Decorates another OrderedBidiMap to ensure it can't be altered. |
UnmodifiableSortedBidiMap.java | Class | Decorates another SortedBidiMap to ensure it can't be altered. |