activemq-cpp-3.6.0
|
Map template that wraps around a std::map to provide a more user-friendly interface and to provide common functions that do not exist in std::map. More...
#include <src/main/decaf/util/concurrent/ConcurrentStlMap.h>
Public Member Functions | |||||||||||
ConcurrentStlMap () | |||||||||||
Default constructor - does nothing. | |||||||||||
ConcurrentStlMap (const ConcurrentStlMap &source) | |||||||||||
Copy constructor - copies the content of the given map into this one. | |||||||||||
ConcurrentStlMap (const Map< K, V > &source) | |||||||||||
Copy constructor - copies the content of the given map into this one. | |||||||||||
virtual | ~ConcurrentStlMap () | ||||||||||
virtual bool | equals (const ConcurrentStlMap &source) const | ||||||||||
| |||||||||||
virtual bool | equals (const Map< K, V > &source) const | ||||||||||
Compares the specified object with this map for equality. | |||||||||||
virtual void | copy (const ConcurrentStlMap &source) | ||||||||||
| |||||||||||
virtual void | copy (const Map< K, V > &source) | ||||||||||
Copies the content of the source map into this map. | |||||||||||
virtual void | clear () | ||||||||||
Removes all of the mappings from this map (optional operation).The map will be empty after this call returns.
| |||||||||||
virtual bool | containsKey (const K &key) const | ||||||||||
Returns true if this map contains a mapping for the specified key.More formally, returns true if and only if this map contains a mapping for a key k such that (key == k). (There can be at most one such mapping.)
| |||||||||||
virtual bool | containsValue (const V &value) const | ||||||||||
Returns true if this map maps one or more keys to the specified value.More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==v). This operation will probably require time linear in the map size for most implementations of the Map interface.
| |||||||||||
virtual bool | isEmpty () const | ||||||||||
| |||||||||||
virtual int | size () const | ||||||||||
| |||||||||||
virtual V & | get (const K &key) | ||||||||||
Gets the value mapped to the specified key in the Map.If there is no element in the map whose key is equivalent to the key provided then a NoSuchElementException is thrown.
| |||||||||||
virtual const V & | get (const K &key) const | ||||||||||
Gets the value mapped to the specified key in the Map.If there is no element in the map whose key is equivalent to the key provided then a NoSuchElementException is thrown.
| |||||||||||
virtual bool | put (const K &key, const V &value) | ||||||||||
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)
| |||||||||||
virtual bool | put (const K &key, const V &value, V &oldValue) | ||||||||||
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)This method accepts a reference to a value which will be assigned the previous value for the given key (if any). If there was no previous mapping for the given key the out value is not written to. A return of true indicates that a value was replaced by this put operation.
| |||||||||||
virtual void | putAll (const ConcurrentStlMap< K, V, COMPARATOR > &other) | ||||||||||
| |||||||||||
virtual void | putAll (const Map< K, V > &other) | ||||||||||
Copies all of the mappings from the specified map to this map (optional operation).The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
| |||||||||||
virtual V | remove (const K &key) | ||||||||||
Removes the value (key/value pair) for the specified key from the map, returns a copy of the value that was mapped to the key.Care must be taken when using this operation as it will throw an exception if there is no mapping for the given key.
| |||||||||||
bool | putIfAbsent (const K &key, const V &value) | ||||||||||
If the specified key is not already associated with a value, associate it with the given value. | |||||||||||
bool | remove (const K &key, const V &value) | ||||||||||
Remove entry for key only if currently mapped to given value. | |||||||||||
bool | replace (const K &key, const V &oldValue, const V &newValue) | ||||||||||
Replace entry for key only if currently mapped to given value. | |||||||||||
V | replace (const K &key, const V &value) | ||||||||||
Replace entry for key only if currently mapped to some value. | |||||||||||
virtual Set< MapEntry< K, V > > & | entrySet () | ||||||||||
Returns a Set view of the mappings contained in this map. | |||||||||||
virtual const Set< MapEntry< K, V > > & | entrySet () const | ||||||||||
virtual Set< K > & | keySet () | ||||||||||
Returns a Set view of the keys contained in this map. | |||||||||||
virtual const Set< K > & | keySet () const | ||||||||||
virtual Collection< V > & | values () | ||||||||||
Returns a Collection view of the values contained in this map. | |||||||||||
virtual const Collection< V > & | values () const | ||||||||||
virtual void | lock () | ||||||||||
Locks the object. | |||||||||||
virtual bool | tryLock () | ||||||||||
Attempts to Lock the object, if the lock is already held by another thread than this method returns false. | |||||||||||
virtual void | unlock () | ||||||||||
Unlocks the object. | |||||||||||
virtual void | wait () | ||||||||||
Waits on a signal from this object, which is generated by a call to Notify. | |||||||||||
virtual void | wait (long long millisecs) | ||||||||||
Waits on a signal from this object, which is generated by a call to Notify. | |||||||||||
virtual void | wait (long long millisecs, int nanos) | ||||||||||
Waits on a signal from this object, which is generated by a call to Notify. | |||||||||||
virtual void | notify () | ||||||||||
Signals a waiter on this object that it can now wake up and continue. | |||||||||||
virtual void | notifyAll () | ||||||||||
Signals the waiters on this object that it can now wake up and continue. | |||||||||||
Public Member Functions inherited from decaf::util::concurrent::ConcurrentMap< K, V > | |||||||||||
virtual | ~ConcurrentMap () | ||||||||||
Public Member Functions inherited from decaf::util::Map< K, V > | |||||||||||
Map () | |||||||||||
Default constructor - does nothing. | |||||||||||
virtual | ~Map () | ||||||||||
Public Member Functions inherited from decaf::util::concurrent::Synchronizable | |||||||||||
virtual | ~Synchronizable () |
Map template that wraps around a std::map to provide a more user-friendly interface and to provide common functions that do not exist in std::map.
This version of Map extends the ConcurrentMap inteface and implements all the methods defined in that interface. Unlike a Java ConcurrentHashMap this implementations synchronizes all methods such that any call to this class will block if another thread is already holding a lock, much like the Java HashTable.
|
inline |
Default constructor - does nothing.
|
inline |
Copy constructor - copies the content of the given map into this one.
source | The source map. |
|
inline |
Copy constructor - copies the content of the given map into this one.
source | The source map. |
|
inlinevirtual |
|
inlinevirtual |
Removes all of the mappings from this map (optional operation).The map will be empty after this call returns.
UnsupportedOperationException | if the clear operation is not supported by this map. |
Implements decaf::util::Map< K, V >.
Referenced by decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::copy().
|
inlinevirtual |
Returns true if this map contains a mapping for the specified key.More formally, returns true if and only if this map contains a mapping for a key k such that (key == k). (There can be at most one such mapping.)
key | The key to look up. |
Implements decaf::util::Map< K, V >.
Referenced by decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::equals(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::put(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::putIfAbsent(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::remove(), and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::replace().
|
inlinevirtual |
Returns true if this map maps one or more keys to the specified value.More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==v). This operation will probably require time linear in the map size for most implementations of the Map interface.
value | The Value to look up in this Map. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
|
inlinevirtual |
Copies the content of the source map into this map.
Erases all existing mappings in this map. The copy is performed by using the entrySet of the source Map and iterating over those entries, inserting each into the target.
source | The source object to copy from. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Returns a Set view of the mappings contained in this map.
The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
|
inlinevirtual |
Compares the specified object with this map for equality.
Returns true if the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.
source | Map to compare to this one. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Gets the value mapped to the specified key in the Map.If there is no element in the map whose key is equivalent to the key provided then a NoSuchElementException is thrown.
key | The search key whose value should be returned if present. |
NoSuchElementException | if the key requests doesn't exist in the Map. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Gets the value mapped to the specified key in the Map.If there is no element in the map whose key is equivalent to the key provided then a NoSuchElementException is thrown.
key | The search key whose value should be returned if present. |
NoSuchElementException | if the key requests doesn't exist in the Map. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Returns a Set view of the keys contained in this map.
The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Implements decaf::util::Map< K, V >.
Referenced by decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::equals().
|
inlinevirtual |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Locks the object.
RuntimeException | if an error occurs while locking the object. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Signals a waiter on this object that it can now wake up and continue.
Must have this object locked before calling.
IllegalMonitorStateException | - if the current thread is not the owner of the the Synchronizable Object. |
RuntimeException | if an error occurs while notifying one of the waiting threads. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Signals the waiters on this object that it can now wake up and continue.
Must have this object locked before calling.
IllegalMonitorStateException | - if the current thread is not the owner of the the Synchronizable Object. |
RuntimeException | if an error occurs while notifying the waiting threads. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)
key | The target key. |
value | The value to be set. |
UnsupportedOperationException | if this map is unmodifiable. |
IllegalArgumentException | if some property of the specified key or value prevents it from being stored in this map |
Implements decaf::util::Map< K, V >.
Referenced by decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::putAll(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::putIfAbsent(), and decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::replace().
|
inlinevirtual |
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)This method accepts a reference to a value which will be assigned the previous value for the given key (if any). If there was no previous mapping for the given key the out value is not written to. A return of true indicates that a value was replaced by this put operation.
key | The target key. |
value | The value to be set. |
oldValue | (out) The value previously held in the mapping for this key. . |
UnsupportedOperationException | if this map is unmodifiable. |
IllegalArgumentException | if some property of the specified key or value prevents it from being stored in this map |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
|
inlinevirtual |
Copies all of the mappings from the specified map to this map (optional operation).The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
UnsupportedOperationException | If the implementing class does not support the putAll operation. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
If the specified key is not already associated with a value, associate it with the given value.
This is equivalent to
if( !map.containsKey( key ) ) { map.put( key, value ); return true; } else { return false; }
except that the action is performed atomically.
key | The key to map the value to. |
value | The value to map to the given key. |
UnsupportedOperationException | if the put operation is not supported by this map |
Implements decaf::util::concurrent::ConcurrentMap< K, V >.
|
inlinevirtual |
Removes the value (key/value pair) for the specified key from the map, returns a copy of the value that was mapped to the key.Care must be taken when using this operation as it will throw an exception if there is no mapping for the given key.
key | The search key whose mapping is to be removed. |
NoSuchElementException | if this key is not in the Map. |
UnsupportedOperationException | if this map is unmodifiable. |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Remove entry for key only if currently mapped to given value.
Acts as
if( map.containsKey( key ) && ( map.get( key ) == value ) ) { map.remove( key ); return true; } else { return false; }
except that the action is performed atomically.
key | key with which the specified value is associated. |
value | value associated with the specified key. |
Implements decaf::util::concurrent::ConcurrentMap< K, V >.
|
inlinevirtual |
Replace entry for key only if currently mapped to given value.
Acts as
if( map.containsKey( key ) && ( map.get( key ) == oldValue ) ) { map.put( key, newValue ); return true; } else { return false; }
except that the action is performed atomically.
key | key with which the specified value is associated. |
oldValue | value expected to be associated with the specified key. |
newValue | value to be associated with the specified key. |
Implements decaf::util::concurrent::ConcurrentMap< K, V >.
|
inlinevirtual |
Replace entry for key only if currently mapped to some value.
Acts as
if( map.containsKey( key ) ) { return map.put( key, value ); } else { throw NoSuchElementException(...); };
except that the action is performed atomically.
key | key with which the specified value is associated. |
value | value to be associated with the specified key. |
NoSuchElementException | if there was no previous mapping. |
Implements decaf::util::concurrent::ConcurrentMap< K, V >.
|
inlinevirtual |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Attempts to Lock the object, if the lock is already held by another thread than this method returns false.
RuntimeException | if an error occurs while locking the object. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Unlocks the object.
RuntimeException | if an error occurs while unlocking the object. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Returns a Collection view of the values contained in this map.
The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations. For the const version of this method the Collection can only be used as a view into the Map.
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Implements decaf::util::Map< K, V >.
|
inlinevirtual |
Waits on a signal from this object, which is generated by a call to Notify.
Must have this object locked before calling.
RuntimeException | if an error occurs while waiting on the object. |
InterruptedException | if the wait is interrupted before it completes. |
IllegalMonitorStateException | - if the current thread is not the owner of the the Synchronizable Object. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Waits on a signal from this object, which is generated by a call to Notify.
Must have this object locked before calling. This wait will timeout after the specified time interval.
millisecs | the time in milliseconds to wait, or WAIT_INIFINITE |
RuntimeException | if an error occurs while waiting on the object. |
InterruptedException | if the wait is interrupted before it completes. |
IllegalMonitorStateException | - if the current thread is not the owner of the the Synchronizable Object. |
Implements decaf::util::concurrent::Synchronizable.
|
inlinevirtual |
Waits on a signal from this object, which is generated by a call to Notify.
Must have this object locked before calling. This wait will timeout after the specified time interval. This method is similar to the one argument wait function except that it add a finer grained control over the amount of time that it waits by adding in the additional nanosecond argument.
NOTE: The ability to wait accurately at a nanosecond scale depends on the platform and OS that the Decaf API is running on, some systems do not provide an accurate enough clock to provide this level of granularity.
millisecs | the time in milliseconds to wait, or WAIT_INIFINITE |
nanos | additional time in nanoseconds with a range of 0-999999 |
IllegalArgumentException | if an error occurs or the nanos argument is not in the range of [0-999999] |
RuntimeException | if an error occurs while waiting on the object. |
InterruptedException | if the wait is interrupted before it completes. |
IllegalMonitorStateException | - if the current thread is not the owner of the the Synchronizable Object. |
Implements decaf::util::concurrent::Synchronizable.