static class TreeBidiMap.Inverse extends java.lang.Object implements OrderedBidiMap
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set |
entrySet
Store the entrySet once created.
|
private java.util.Set |
keySet
Store the keySet once created.
|
private TreeBidiMap |
main
The parent map.
|
private java.util.Set |
valuesSet
Store the valuesSet once created.
|
| Constructor and Description |
|---|
Inverse(TreeBidiMap main)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set |
entrySet() |
boolean |
equals(java.lang.Object obj) |
java.lang.Object |
firstKey()
Gets the first key currently in this map.
|
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.
|
OrderedBidiMap |
inverseOrderedBidiMap()
Gets a view of this map where the keys and values are reversed.
|
boolean |
isEmpty() |
java.util.Set |
keySet() |
java.lang.Object |
lastKey()
Gets the last key currently in this map.
|
MapIterator |
mapIterator()
Obtains a
MapIterator over the map. |
java.lang.Object |
nextKey(java.lang.Object key)
Gets the next key after the one specified.
|
OrderedMapIterator |
orderedMapIterator()
Obtains an
OrderedMapIterator over the map. |
java.lang.Object |
previousKey(java.lang.Object key)
Gets the previous key before the one specified.
|
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() |
private final TreeBidiMap main
private java.util.Set keySet
private java.util.Set valuesSet
private java.util.Set entrySet
Inverse(TreeBidiMap main)
main - the main mappublic int size()
size in interface java.util.Mappublic boolean isEmpty()
isEmpty in interface java.util.Mappublic java.lang.Object get(java.lang.Object key)
get in interface java.util.Mappublic 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).
public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Mappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Mappublic java.lang.Object firstKey()
OrderedMapfirstKey in interface OrderedMappublic java.lang.Object lastKey()
OrderedMaplastKey in interface OrderedMappublic java.lang.Object nextKey(java.lang.Object key)
OrderedMapnextKey in interface OrderedMapkey - the key to search for next frompublic java.lang.Object previousKey(java.lang.Object key)
OrderedMappreviousKey in interface OrderedMapkey - the key to search for previous frompublic 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
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 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 fornull if nothing removedpublic void clear()
clear in interface java.util.Mappublic java.util.Set keySet()
keySet in interface java.util.Mappublic java.util.Collection values()
values in interface java.util.Mappublic java.util.Set entrySet()
entrySet in interface java.util.Mappublic MapIterator mapIterator()
BidiMapMapIterator over the map.
A map iterator is an efficient way of iterating over maps. It does not require that the map is stored using Map Entry objects which can increase performance.
BidiMap map = new DualHashBidiMap();
MapIterator it = map.mapIterator();
while (it.hasNext()) {
Object key = it.next();
Object value = it.getValue();
it.setValue("newValue");
}
mapIterator in interface BidiMapmapIterator in interface IterableMappublic OrderedMapIterator orderedMapIterator()
OrderedMapOrderedMapIterator over the map.
A ordered map iterator is an efficient way of iterating over maps in both directions.
BidiMap map = new TreeBidiMap();
MapIterator it = map.mapIterator();
while (it.hasNext()) {
Object key = it.next();
Object value = it.getValue();
it.setValue("newValue");
Object previousKey = it.previous();
}
orderedMapIterator in interface OrderedMappublic BidiMap inverseBidiMap()
OrderedBidiMapChanges to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed equally.
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.
Implementations must return an OrderedBidiMap instance,
usually by forwarding to inverseOrderedBidiMap().
inverseBidiMap in interface BidiMapinverseBidiMap in interface OrderedBidiMappublic OrderedBidiMap inverseOrderedBidiMap()
OrderedBidiMapChanges to one map will be visible in the other and vice versa. This enables both directions of the map to be accessed equally.
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.
inverseOrderedBidiMap in interface OrderedBidiMappublic 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