Package jadex.commons.collection
Class RwMapWrapper<K,V>
- java.lang.Object
-
- jadex.commons.collection.RwMapWrapper<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<K,V>
map
The wrapped map.protected RwAutoLock
rwautolock
-
Constructor Summary
Constructors Constructor Description RwMapWrapper(java.util.Map<K,V> map)
Creates the wrapper.RwMapWrapper(java.util.Map<K,V> map, boolean fair)
Creates the wrapper.RwMapWrapper(java.util.Map<K,V> map, java.util.concurrent.locks.ReadWriteLock lock)
Creates the wrapper with a specific internal lock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the map.boolean
containsKey(java.lang.Object key)
Returns if the map contains a key.boolean
containsValue(java.lang.Object value)
Returns if the map contains a value.java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
Returns the entry set.V
get(java.lang.Object key)
Gets the value for the key.java.util.concurrent.locks.ReadWriteLock
getLock()
Gets the internal lock.java.util.concurrent.locks.Lock
getReadLock()
Gets the read lock for manual locking.java.util.concurrent.locks.Lock
getWriteLock()
Gets the write lock for manual locking.boolean
isEmpty()
Returns if map is empty.java.util.Set<K>
keySet()
Returns the key set.V
put(K key, V value)
Puts a key-value pair.void
putAll(java.util.Map<? extends K,? extends V> m)
Puts all key-value pairs into map.IAutoLock
readLock()
Locks the read lock for resource-based locking.V
remove(java.lang.Object key)
Removes a key-value pair.int
size()
Returns the size of the map.java.util.Collection<V>
values()
Returns the key values.IAutoLock
writeLock()
Locks the write lock for resource-based locking.
-
-
-
Field Detail
-
rwautolock
protected RwAutoLock rwautolock
-
-
Constructor Detail
-
RwMapWrapper
public RwMapWrapper(java.util.Map<K,V> map)
Creates the wrapper.- Parameters:
map
- The wrapped map.
-
RwMapWrapper
public RwMapWrapper(java.util.Map<K,V> map, java.util.concurrent.locks.ReadWriteLock lock)
Creates the wrapper with a specific internal lock.- Parameters:
map
- The wrapped map.
-
-
Method Detail
-
size
public int size()
Returns the size of the map.
-
isEmpty
public boolean isEmpty()
Returns if map is empty.
-
containsKey
public boolean containsKey(java.lang.Object key)
Returns if the map contains a key.
-
containsValue
public boolean containsValue(java.lang.Object value)
Returns if the map contains a value.
-
get
public V get(java.lang.Object key)
Gets the value for the key.
-
remove
public V remove(java.lang.Object key)
Removes a key-value pair.
-
putAll
public void putAll(java.util.Map<? extends K,? extends V> m)
Puts all key-value pairs into map.
-
keySet
public java.util.Set<K> keySet()
Returns the key set. Warning: Use manual locking.
-
values
public java.util.Collection<V> values()
Returns the key values. Warning: Use manual locking.
-
entrySet
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Returns the entry set. Warning: Use manual locking.
-
readLock
public IAutoLock readLock()
Locks the read lock for resource-based locking.
-
writeLock
public IAutoLock writeLock()
Locks the write lock for resource-based locking.
-
getReadLock
public java.util.concurrent.locks.Lock getReadLock()
Gets the read lock for manual locking.- Specified by:
getReadLock
in interfaceIRwMap<K,V>
-
getWriteLock
public java.util.concurrent.locks.Lock getWriteLock()
Gets the write lock for manual locking.- Specified by:
getWriteLock
in interfaceIRwMap<K,V>
-
-