Package jadex.collection
Class RwMapWrapper<K,V>
java.lang.Object
jadex.collection.RwMapWrapper<K,V>
- All Implemented Interfaces:
IRwDataStructure,Map<K,V>
Thread-safe wrapper for maps that uses a read/write lock.
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRwMapWrapper(Map<K, V> map) Creates the wrapper.RwMapWrapper(Map<K, V> map, boolean fair) Creates the wrapper.RwMapWrapper(Map<K, V> map, ReadWriteLock lock) Creates the wrapper with a specific internal lock. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the map.booleancontainsKey(Object key) Returns if the map contains a key.booleancontainsValue(Object value) Returns if the map contains a value.entrySet()Returns the entry set.Gets the value for the key.jadex.common.RwAutoLockGets the internal auto lock.booleanisEmpty()Returns if map is empty.keySet()Returns the key set.Puts a key-value pair.voidPuts all key-value pairs into map.Removes a key-value pair.intsize()Returns the size of the map.values()Returns the key values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jadex.collection.IRwDataStructure
getLock, getReadLock, getWriteLock, readLock, writeLockMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
map
The wrapped map.
-
-
Constructor Details
-
RwMapWrapper
Creates the wrapper.- Parameters:
map- The wrapped map.
-
RwMapWrapper
Creates the wrapper with a specific internal lock.- Parameters:
map- The wrapped map.
-
RwMapWrapper
Creates the wrapper.- Parameters:
map- The wrapped map.fair- Set true for fair-mode lock.
-
-
Method Details
-
size
public int size()Returns the size of the map. -
isEmpty
public boolean isEmpty()Returns if map is empty. -
containsKey
Returns if the map contains a key.- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
Returns if the map contains a value.- Specified by:
containsValuein interfaceMap<K,V>
-
get
Gets the value for the key. -
put
Puts a key-value pair. -
remove
Removes a key-value pair. -
putAll
Puts all key-value pairs into map. -
clear
public void clear()Clears the map. -
keySet
Returns the key set. Warning: Use manual locking. -
values
Returns the key values. Warning: Use manual locking. -
entrySet
Returns the entry set. Warning: Use manual locking. -
getAutoLock
public jadex.common.RwAutoLock getAutoLock()Gets the internal auto lock.- Specified by:
getAutoLockin interfaceIRwDataStructure- Returns:
- The lock.
-