Class AbstractDualBidiMap<K,V> 
- Type Parameters:
- K- the type of the keys in the map
- V- the type of the values in the map
- All Implemented Interfaces:
- Map<K,,- V> - BidiMap<K,,- V> - Get<K,,- V> - IterableGet<K,,- V> - IterableMap<K,,- V> - Put<K,- V> 
- Direct Known Subclasses:
- DualHashBidiMap,- DualLinkedHashBidiMap,- DualTreeBidiMap
BidiMap implemented using two maps.
 
 An implementation can be written simply by implementing the
 createBidiMap(Map, Map, BidiMap) method.
 
- Since:
- 3.0
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classInner class MapIterator.protected static classInner class EntrySet.protected static classInner class EntrySetIterator.protected static classInner class KeySet.protected static classInner class KeySetIterator.protected static classInner class MapEntry.protected static classInner class Values.protected static classInner class ValuesIterator.protected static classInner class View.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates an empty map, initialized bycreateMap.protectedCreates an empty map using the two maps specified as storage.protectedConstructs a map that decorates the specified maps, used by the subclasscreateBidiMapimplementation.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Removes all of the mappings from this map.booleancontainsKey(Object key) Tests for presence of a given key.booleancontainsValue(Object value) Tests for presence of a given value.Creates a new instance of the subclass.createEntrySetIterator(Iterator<Map.Entry<K, V>> iterator) Creates an entry set iterator.createKeySetIterator(Iterator<K> iterator) Creates a key set iterator.createValuesIterator(Iterator<V> iterator) Creates a values iterator.entrySet()Gets an entrySet view of the map.booleanGets a value at a given key.Gets the key that is currently mapped to the specified value.inthashCode()Gets a view of this map where the keys and values are reversed.booleanisEmpty()Tests whether this instance contains any key-value mappings.keySet()Gets a keySet view of the map.Obtains aMapIteratorover the map.Puts the key-value pair into the map, replacing any previous pair.voidCopies all of the mappings from the specified map to this map.Remove a key-value mappings.removeValue(Object value) Removes the key-value pair that is currently mapped to the specified value (optional operation).intsize()Gets the number of key-value mappings in this map.toString()values()Gets a values view of the map.Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
- 
Constructor Details- 
AbstractDualBidiMapprotected AbstractDualBidiMap()Creates an empty map, initialized bycreateMap.This constructor remains in place for deserialization. All other usage is deprecated in favor of AbstractDualBidiMap(Map, Map).
- 
AbstractDualBidiMapCreates 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.- Parameters:
- normalMap- the normal direction map
- reverseMap- the reverse direction map
- Since:
- 3.1
 
- 
AbstractDualBidiMapConstructs a map that decorates the specified maps, used by the subclasscreateBidiMapimplementation.- Parameters:
- normalMap- the normal direction map
- reverseMap- the reverse direction map
- inverseBidiMap- the inverse BidiMap
 
 
- 
- 
Method Details- 
clear
- 
containsKeyDescription copied from interface:GetTests for presence of a given key.- Specified by:
- containsKeyin interface- Get<K,- V> 
- Specified by:
- containsKeyin interface- Map<K,- V> 
- Parameters:
- key- key whose presence in this map is to be tested
- Returns:
- trueif this map contains a mapping for the specified key
- See Also:
 
- 
containsValueDescription copied from interface:GetTests for presence of a given value.- Specified by:
- containsValuein interface- Get<K,- V> 
- Specified by:
- containsValuein interface- Map<K,- V> 
- Parameters:
- value- value whose presence in this map is to be tested
- Returns:
- trueif this map maps one or more keys to the specified value
- See Also:
 
- 
createBidiMapprotected abstract BidiMap<V,K> createBidiMap(Map<V, K> normalMap, Map<K, V> reverseMap, BidiMap<K, V> inverseMap) Creates a new instance of the subclass.- Parameters:
- normalMap- the normal direction map
- reverseMap- the reverse direction map
- inverseMap- this map, which is the inverse in the new map
- Returns:
- the bidi map
 
- 
createEntrySetIterator
- 
createKeySetIteratorCreates a key set iterator. Subclasses can override this to return iterators with different properties.- Parameters:
- iterator- the iterator to decorate
- Returns:
- the keySet iterator
 
- 
createValuesIteratorCreates a values iterator. Subclasses can override this to return iterators with different properties.- Parameters:
- iterator- the iterator to decorate
- Returns:
- the values iterator
 
- 
entrySetGets 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). 
- 
equals
- 
getDescription copied from interface:GetGets a value at a given key.
- 
getKeyDescription copied from interface:BidiMapGets the key that is currently mapped to the specified value.If the value is not contained in the map, nullis returned.Implementations should seek to make this method perform equally as well as get(Object).
- 
hashCode
- 
inverseBidiMapDescription copied from interface:BidiMapGets 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.- Specified by:
- inverseBidiMapin interface- BidiMap<K,- V> 
- Returns:
- an inverted bidirectional map
 
- 
isEmpty
- 
keySet
- 
mapIteratorObtains aMapIteratorover the map. The iterator implementsAbstractDualBidiMap.BidiMapIterator. This implementation relies on the entrySet iterator.- Specified by:
- mapIteratorin interface- IterableGet<K,- V> 
- Returns:
- a map iterator
 
- 
putDescription copied from interface:BidiMapPuts 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
- 
putAllDescription copied from interface:PutCopies all of the mappings from the specified map to this map.
- 
removeDescription copied from interface:GetRemove a key-value mappings.
- 
removeValueDescription copied from interface:BidiMapRemoves the key-value pair that is currently mapped to the specified value (optional operation).If the value is not contained in the map, nullis returned.Implementations should seek to make this method perform equally as well as remove(Object).- Specified by:
- removeValuein interface- BidiMap<K,- V> 
- Parameters:
- value- the value to find the key-value pair for
- Returns:
- the key that was removed, nullif nothing removed
 
- 
size
- 
toString
- 
valuesGets 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.
 
-