Class ConcurrentUniqueMap<K,V>
java.lang.Object
com.dianxin.tori.base.collections.ConcurrentUniqueMap<K,V>
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
- All Implemented Interfaces:
UniqueMap<K,V>
@ReleasedSince("26.10.0")
public class ConcurrentUniqueMap<K,V>
extends Object
implements UniqueMap<K,V>
A thread-safe, bidirectional implementation of the
UniqueMap interface.
This class guarantees bijective uniqueness across concurrent threads using
a ReadWriteLock, allowing concurrent non-blocking reads while ensuring
strict atomicity for mutation operations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.dianxin.tori.base.collections.UniqueMap
UniqueMap.Entry<K,V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(K key) Returnstrueif this map contains a mapping for the specified key.booleancontainsValue(V value) Returnstrueif this map maps one or more keys to the specified value.@NonNull VReturns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.getAll()Returns an unmodifiableMapview of the mappings contained in this map.@NonNull KgetKeyByValue(V value) Returns the key associated with the specified value, ornullif this map contains no mapping for the value.voidAssociates the specified value with the specified key in this map.voidremoveByKey(K key) Removes the mapping for a key from this map if it is present.voidremoveByValue(V value) Removes the mapping for a value from this map if it is present.intsize()Returns the number of key-value mappings in this map.
-
Constructor Details
-
ConcurrentUniqueMap
public ConcurrentUniqueMap() -
ConcurrentUniqueMap
-
-
Method Details
-
putUnique
Description copied from interface:UniqueMapAssociates the specified value with the specified key in this map. Both the key and the value must be unique within the map. -
get
Description copied from interface:UniqueMapReturns the value to which the specified key is mapped, ornullif this map contains no mapping for the key. -
getKeyByValue
Description copied from interface:UniqueMapReturns the key associated with the specified value, ornullif this map contains no mapping for the value.- Specified by:
getKeyByValuein interfaceUniqueMap<K,V> - Parameters:
value- the value whose associated key is to be returned- Returns:
- the key associated with the specified value, or
null
-
containsKey
Description copied from interface:UniqueMapReturnstrueif this map contains a mapping for the specified key.- Specified by:
containsKeyin interfaceUniqueMap<K,V> - Parameters:
key- the key whose presence in this map is to be tested- Returns:
trueif this map contains a mapping for the specified key
-
containsValue
Description copied from interface:UniqueMapReturnstrueif this map maps one or more keys to the specified value.- Specified by:
containsValuein interfaceUniqueMap<K,V> - Parameters:
value- the value whose presence in this map is to be tested- Returns:
trueif this map maps one or more keys to the specified value
-
removeByKey
Description copied from interface:UniqueMapRemoves the mapping for a key from this map if it is present. Also removes the corresponding value from the bidirectional mapping.- Specified by:
removeByKeyin interfaceUniqueMap<K,V> - Parameters:
key- the key whose mapping is to be removed from the map
-
removeByValue
Description copied from interface:UniqueMapRemoves the mapping for a value from this map if it is present. Also removes the corresponding key from the bidirectional mapping.- Specified by:
removeByValuein interfaceUniqueMap<K,V> - Parameters:
value- the value whose mapping is to be removed from the map
-
size
public int size()Description copied from interface:UniqueMapReturns the number of key-value mappings in this map. -
getAll
Description copied from interface:UniqueMapReturns an unmodifiableMapview of the mappings contained in this map.
-