|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.apache.commons.collections.bidimap.AbstractDualBidiMap
Abstract BidiMap implemented using two maps.
An implementation can be written simply by implementing the
createMap method.
DualHashBidiMap,
DualTreeBidiMap| Method Summary | |
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
Gets an entrySet view of the map. |
boolean |
equals(java.lang.Object obj)
|
java.lang.Object |
get(java.lang.Object key)
|
java.lang.Object |
getKey(java.lang.Object value)
Gets the key that is currently mapped to the specified value. |
int |
hashCode()
|
BidiMap |
inverseBidiMap()
Gets a view of this map where the keys and values are reversed. |
boolean |
isEmpty()
|
java.util.Set |
keySet()
Gets a keySet view of the map. |
MapIterator |
mapIterator()
Obtains a MapIterator over the map. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Puts the key-value pair into the map, replacing any previous pair. |
void |
putAll(java.util.Map map)
|
java.lang.Object |
remove(java.lang.Object key)
|
java.lang.Object |
removeValue(java.lang.Object value)
Removes the key-value pair that is currently mapped to the specified value (optional operation). |
int |
size()
|
java.lang.String |
toString()
|
java.util.Collection |
values()
Gets a values view of the map. |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
public java.lang.Object get(java.lang.Object key)
get in interface java.util.Mappublic int size()
size in interface java.util.Mappublic boolean isEmpty()
isEmpty in interface java.util.Mappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Mappublic boolean equals(java.lang.Object obj)
equals in interface java.util.Mapequals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.MaphashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
BidiMapWhen 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
put in interface BidiMapkey - the key to storevalue - the value to store
public void putAll(java.util.Map map)
putAll in interface java.util.Mappublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mappublic void clear()
clear in interface java.util.Mappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Mappublic MapIterator mapIterator()
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).
mapIterator in interface BidiMappublic java.lang.Object getKey(java.lang.Object value)
BidiMap
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).
getKey in interface BidiMapvalue - the value to find the key for
null if not foundpublic java.lang.Object removeValue(java.lang.Object value)
BidiMap
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).
removeValue in interface BidiMapvalue - the value to find the key-value pair for
null if nothing removedpublic BidiMap inverseBidiMap()
BidiMap
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.
inverseBidiMap in interface BidiMappublic java.util.Set keySet()
keySet in interface java.util.Mappublic java.util.Collection values()
values in interface java.util.Mappublic java.util.Set entrySet()
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).
entrySet in interface java.util.Map
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||