java.lang.Object | |
↳ | org.apache.commons.collections.bidimap.AbstractDualBidiMap |
Known Direct Subclasses |
Abstract BidiMap
implemented using two maps.
An implementation can be written simply by implementing the
createMap
method.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AbstractDualBidiMap.BidiMapIterator | Inner class MapIterator. | ||||||||||
AbstractDualBidiMap.EntrySet | Inner class EntrySet. | ||||||||||
AbstractDualBidiMap.EntrySetIterator | Inner class EntrySetIterator. | ||||||||||
AbstractDualBidiMap.KeySet | Inner class KeySet. | ||||||||||
AbstractDualBidiMap.KeySetIterator | Inner class KeySetIterator. | ||||||||||
AbstractDualBidiMap.MapEntry | Inner class MapEntry. | ||||||||||
AbstractDualBidiMap.Values | Inner class Values. | ||||||||||
AbstractDualBidiMap.ValuesIterator | Inner class ValuesIterator. | ||||||||||
AbstractDualBidiMap.View | Inner class View. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
entrySet | View of the entries. | ||||||||||
inverseBidiMap | Inverse view of this map. | ||||||||||
keySet | View of the keys. | ||||||||||
maps | Delegate map array. | ||||||||||
values | View of the values. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an empty map, initialised by
createMap . | |||||||||||
Creates an empty map using the two maps specified as storage.
| |||||||||||
Constructs a map that decorates the specified maps,
used by the subclass
createBidiMap implementation. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets an entrySet view of the map.
| |||||||||||
Gets the key that is currently mapped to the specified value.
| |||||||||||
Gets a view of this map where the keys and values are reversed.
| |||||||||||
Gets a keySet view of the map.
| |||||||||||
Obtains a
MapIterator over the map. | |||||||||||
Puts the key-value pair into the map, replacing any previous pair.
| |||||||||||
Removes the key-value pair that is currently mapped to the specified
value (optional operation).
| |||||||||||
Gets a values view of the map.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new instance of the subclass.
| |||||||||||
Creates an entry set iterator.
| |||||||||||
Creates a key set iterator.
| |||||||||||
This method is deprecated.
For constructors, use the new two map constructor.
For deserialization, populate the maps array directly in readObject.
| |||||||||||
Creates a values iterator.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Map
| |||||||||||
From interface
org.apache.commons.collections.BidiMap
| |||||||||||
From interface
org.apache.commons.collections.IterableMap
|
Delegate map array. The first map contains standard entries, and the second contains inverses.
Creates an empty map, initialised by createMap
.
This constructor remains in place for deserialization.
All other usage is deprecated in favour of
AbstractDualBidiMap(Map, Map)
.
Creates an empty map using the two maps specified as storage.
The two maps must be a matching pair, normal and reverse. They will typically both be empty.
Neither map is validated, so nulls may be passed in.
If you choose to do this then the subclass constructor must populate
the maps[]
instance variable itself.
normalMap | the normal direction map |
---|---|
reverseMap | the reverse direction map |
Constructs a map that decorates the specified maps,
used by the subclass createBidiMap
implementation.
normalMap | the normal direction map |
---|---|
reverseMap | the reverse direction map |
inverseBidiMap | the inverse BidiMap |
Gets an entrySet view of the map. Changes made on the set are reflected in the map. The set supports remove and clear but not add.
The Map Entry setValue() method only allow a new value to be set. If the value being set is already in the map, an IllegalArgumentException is thrown (as setValue cannot change the size of the map).
Gets the key that is currently mapped to the specified value.
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as get(Object)
.
value | the value to find the key for |
---|
null
if not foundGets 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 as a Map
.
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.
Gets a keySet view of the map. Changes made on the view are reflected in the map. The set supports remove and clear but not add.
Obtains a MapIterator
over the map.
The iterator implements ResetableMapIterator
.
This implementation relies on the entrySet iterator.
The setValue() methods only allow a new value to be set. If the value being set is already in the map, an IllegalArgumentException is thrown (as setValue cannot change the size of the map).
Puts the key-value pair into the map, replacing any previous pair.
When adding a key-value pair, the value may already exist in the map against a different key. That mapping is removed, to ensure that the value only occurs once in the inverse map.
BidiMap map1 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("A","C"); // contains A mapped to C, as per Map BidiMap map2 = new DualHashBidiMap(); map.put("A","B"); // contains A mapped to B, as per Map map.put("C","B"); // contains C mapped to B, key A is removed
key | the key to store |
---|---|
value | the value to store |
Removes the key-value pair that is currently mapped to the specified value (optional operation).
If the value is not contained in the map, null
is returned.
Implementations should seek to make this method perform equally as well
as remove(Object)
.
value | the value to find the key-value pair for |
---|
null
if nothing removedGets a values view of the map. Changes made on the view are reflected in the map. The set supports remove and clear but not add.
Creates a new instance of the subclass.
normalMap | the normal direction map |
---|---|
reverseMap | the reverse direction map |
inverseMap | this map, which is the inverse in the new map |
Creates an entry set iterator. Subclasses can override this to return iterators with different properties.
iterator | the iterator to decorate |
---|
Creates a key set iterator. Subclasses can override this to return iterators with different properties.
iterator | the iterator to decorate |
---|
This method is deprecated.
For constructors, use the new two map constructor.
For deserialization, populate the maps array directly in readObject.
Creates a new instance of the map used by the subclass to store data.
This design is deeply flawed and has been deprecated. It relied on subclass data being used during a superclass constructor.
Creates a values iterator. Subclasses can override this to return iterators with different properties.
iterator | the iterator to decorate |
---|