org.omnaest.utils.structure.map.dualmap
Interface DualMap<K,V>
- Type Parameters:
K - V -
- All Superinterfaces:
- Map<K,V>, Serializable
- All Known Implementing Classes:
- LinkedHashDualMap
public interface DualMap<K,V>
- extends Map<K,V>, Serializable
A DualMap is the dual way counterpart of the Map interface.
All DualMap implementations should ensure that both elements are treated as keys, so the search within large sized
DualMaps should be fast using either of the elements.
Be aware of the fact that the key and value indexes can have different sizes, since there can be 1:n relationships being put
into the map, but stored are only the last inserted 1:1 relationship. This means adding (a,c) and (b,c) will result in "b"
being found for a search after the value element "c". "a" will be lost in the key index in this case.
This does differ from the BiMap definition.
- Author:
- Omnaest
- See Also:
Map
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
| Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
contains
boolean contains(Object element)
- Returns true, if the element is contained as key or value
- Parameters:
element -
- Returns:
putAll
DualMap<K,V> putAll(DualMap<? extends K,? extends V> dualMap)
- Parameters:
dualMap -
- Returns:
- this
- See Also:
Map.put(Object, Object),
Map.putAll(Map),
#putAllSecondElementToFirstElement(Map)
invert
DualMap<V,K> invert()
- Returns the same
DualMap instance but with inverted key and value
- Returns:
DualMap
Copyright © 2013. All Rights Reserved.