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 TypeMethodDescriptionvoid
clear()
Clears the map.boolean
containsKey
(Object key) Returns if the map contains a key.boolean
containsValue
(Object value) Returns if the map contains a value.entrySet()
Returns the entry set.Gets the value for the key.jadex.common.RwAutoLock
Gets the internal auto lock.boolean
isEmpty()
Returns if map is empty.keySet()
Returns the key set.Puts a key-value pair.void
Puts all key-value pairs into map.Removes a key-value pair.int
size()
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, wait
Methods inherited from interface jadex.collection.IRwDataStructure
getLock, getReadLock, getWriteLock, readLock, writeLock
Methods 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:
containsKey
in interfaceMap<K,
V>
-
containsValue
Returns if the map contains a value.- Specified by:
containsValue
in 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:
getAutoLock
in interfaceIRwDataStructure
- Returns:
- The lock.
-