org.apache.commons.collections.bidimap
public abstract class AbstractDualBidiMap extends Object implements BidiMap
BidiMap
implemented using two maps.
An implementation can be written simply by implementing the
createMap
method.
Since: Commons Collections 3.0
Version: $Id: AbstractDualBidiMap.java 155406 2005-02-26 12:55:26Z dirkv $
See Also: DualHashBidiMap DualTreeBidiMap
Nested Class Summary | |
---|---|
protected static class | AbstractDualBidiMap.BidiMapIterator
Inner class MapIterator. |
protected static class | AbstractDualBidiMap.EntrySet
Inner class EntrySet. |
protected static class | AbstractDualBidiMap.EntrySetIterator
Inner class EntrySetIterator. |
protected static class | AbstractDualBidiMap.KeySet
Inner class KeySet. |
protected static class | AbstractDualBidiMap.KeySetIterator
Inner class KeySetIterator. |
protected static class | AbstractDualBidiMap.MapEntry
Inner class MapEntry. |
protected static class | AbstractDualBidiMap.Values
Inner class Values. |
protected static class | AbstractDualBidiMap.ValuesIterator
Inner class ValuesIterator. |
protected abstract static class | AbstractDualBidiMap.View
Inner class View. |
Field Summary | |
---|---|
protected Set | entrySet
View of the entries. |
protected BidiMap | inverseBidiMap
Inverse view of this map. |
protected Set | keySet
View of the keys. |
protected Map[] | maps
Delegate map array. |
protected Collection | values
View of the values. |
Constructor Summary | |
---|---|
protected | AbstractDualBidiMap()
Creates an empty map, initialised by createMap .
|
protected | AbstractDualBidiMap(Map normalMap, Map reverseMap)
Creates an empty map using the two maps specified as storage.
|
protected | AbstractDualBidiMap(Map normalMap, Map reverseMap, BidiMap inverseBidiMap)
Constructs a map that decorates the specified maps,
used by the subclass createBidiMap implementation.
|
Method Summary | |
---|---|
void | clear() |
boolean | containsKey(Object key) |
boolean | containsValue(Object value) |
protected abstract BidiMap | createBidiMap(Map normalMap, Map reverseMap, BidiMap inverseMap)
Creates a new instance of the subclass.
|
protected Iterator | createEntrySetIterator(Iterator iterator)
Creates an entry set iterator.
|
protected Iterator | createKeySetIterator(Iterator iterator)
Creates a key set iterator.
|
protected Map | createMap()
Creates a new instance of the map used by the subclass to store data.
|
protected Iterator | createValuesIterator(Iterator iterator)
Creates a values iterator.
|
Set | entrySet()
Gets an entrySet view of the map.
|
boolean | equals(Object obj) |
Object | get(Object key) |
Object | getKey(Object value) |
int | hashCode() |
BidiMap | inverseBidiMap() |
boolean | isEmpty() |
Set | keySet()
Gets a keySet view of the map.
|
MapIterator | mapIterator()
Obtains a MapIterator over the map.
|
Object | put(Object key, Object value) |
void | putAll(Map map) |
Object | remove(Object key) |
Object | removeValue(Object value) |
int | size() |
String | toString() |
Collection | values()
Gets a values view of the map.
|
createMap
.
This constructor remains in place for deserialization. All other usage is deprecated in favour of AbstractDualBidiMap.
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.
Parameters: normalMap the normal direction map reverseMap the reverse direction map
Since: Commons Collections 3.1
createBidiMap
implementation.
Parameters: normalMap the normal direction map reverseMap the reverse direction map inverseBidiMap the inverse BidiMap
Parameters: normalMap the normal direction map reverseMap the reverse direction map inverseMap this map, which is the inverse in the new map
Returns: the inverse map
Parameters: iterator the iterator to decorate
Returns: the entrySet iterator
Parameters: iterator the iterator to decorate
Returns: the keySet iterator
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.
Returns: the map to be used for internal storage
Parameters: iterator the iterator to decorate
Returns: the values iterator
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).
Returns: the entrySet view
Returns: the keySet view
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).
Returns: a map iterator
Returns: the values view