activemq-cpp-3.4.0

decaf::util::StlMap< K, V, COMPARATOR > Class Template Reference

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/StlMap.h>

Inheritance diagram for decaf::util::StlMap< K, V, COMPARATOR >:

Public Member Functions

 StlMap ()
 Default constructor - does nothing.
 StlMap (const StlMap &source)
 Copy constructor - copies the content of the given map into this one.
 StlMap (const Map< K, V, COMPARATOR > &source)
 Copy constructor - copies the content of the given map into this one.
virtual ~StlMap ()
virtual bool equals (const StlMap &source) const
 
virtual bool equals (const Map< K, V, COMPARATOR > &source) const
 Comparison, equality is dependent on the method of determining if the element are equal.
Parameters:
source- Map to compare to this one.
Returns:
true if the Map passed is equal in value to this one.

virtual void copy (const StlMap &source)
 
virtual void copy (const Map< K, V, COMPARATOR > &source)
 Copies the content of the source map into this map.Erases all existing data in this map.

Parameters:
sourceThe source object to copy from.

virtual void clear ()
 Removes all keys and values from this map.
Exceptions:
UnsupportedOperationExceptionif this map is unmodifiable.

virtual bool containsKey (const K &key) const
 Indicates whether or this map contains a value for the given key.
Parameters:
keyThe key to look up.
Returns:
true if this map contains the value, otherwise false.

virtual bool containsValue (const V &value) const
 Indicates whether or this map contains a value for the given value, i.e.they are equal, this is done by operator== so the types must pass equivalence testing in this manner.

Parameters:
valueThe Value to look up.
Returns:
true if this map contains the value, otherwise false.

virtual bool isEmpty () const
 
Returns:
if the Map contains any element or not, TRUE or FALSE

virtual int size () const
 
Returns:
The number of elements (key/value pairs) in this map.

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.
Parameters:
keyThe search key.
Returns:
A reference to the value for the given key.
Exceptions:
NoSuchElementExceptionif the key requests doesn't exist in the Map.

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.
Parameters:
keyThe search key.
Returns:
A {const} reference to the value for the given key.
Exceptions:
NoSuchElementExceptionif the key requests doesn't exist in the Map.

virtual void put (const K &key, const V &value)
 Sets the value for the specified key.
Parameters:
keyThe target key.
valueThe value to be set.
Exceptions:
UnsupportedOperationExceptionif this map is unmodifiable.

virtual void putAll (const StlMap< K, V, COMPARATOR > &other)
 
virtual void putAll (const Map< K, V, COMPARATOR > &other)
 Stores a copy of the Mappings contained in the other Map in this one.
Parameters:
otherA Map instance whose elements are to all be inserted in this Map.
Exceptions:
UnsupportedOperationExceptionIf the implementing class does not support the putAll operation.

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.
Parameters:
keyThe search key.
Returns:
a copy of the element that was previously mapped to the given key
Exceptions:
NoSuchElementExceptionif this key is not in the Map.
UnsupportedOperationExceptionif this map is unmodifiable.

virtual std::vector< K > keySet () const
 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.

Returns:
the entire set of keys in this map as a std::vector.

virtual std::vector< V > values () const
 
Returns:
the entire set of values in this map as a std::vector.

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.

Detailed Description

template<typename K, typename V, typename COMPARATOR = std::less<K>>
class decaf::util::StlMap< K, V, COMPARATOR >

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.

Since:
1.0

Constructor & Destructor Documentation

template<typename K, typename V, typename COMPARATOR = std::less<K>>
decaf::util::StlMap< K, V, COMPARATOR >::StlMap ( ) [inline]

Default constructor - does nothing.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
decaf::util::StlMap< K, V, COMPARATOR >::StlMap ( const StlMap< K, V, COMPARATOR > &  source) [inline]

Copy constructor - copies the content of the given map into this one.

Parameters:
sourceThe source map.
template<typename K, typename V, typename COMPARATOR = std::less<K>>
decaf::util::StlMap< K, V, COMPARATOR >::StlMap ( const Map< K, V, COMPARATOR > &  source) [inline]

Copy constructor - copies the content of the given map into this one.

Parameters:
sourceThe source map.
template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual decaf::util::StlMap< K, V, COMPARATOR >::~StlMap ( ) [inline, virtual]

Member Function Documentation

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::clear ( ) [inline, virtual]

Removes all keys and values from this map.

Exceptions:
UnsupportedOperationExceptionif this map is unmodifiable.

Implements decaf::util::Map< K, V, COMPARATOR >.

Referenced by decaf::util::StlMap< std::string, cms::Topic * >::copy().

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::containsKey ( const K &  key) const [inline, virtual]

Indicates whether or this map contains a value for the given key.

Parameters:
keyThe key to look up.
Returns:
true if this map contains the value, otherwise false.

Implements decaf::util::Map< K, V, COMPARATOR >.

Referenced by decaf::util::StlMap< std::string, cms::Topic * >::equals().

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::containsValue ( const V &  value) const [inline, virtual]

Indicates whether or this map contains a value for the given value, i.e.they are equal, this is done by operator== so the types must pass equivalence testing in this manner.

Parameters:
valueThe Value to look up.
Returns:
true if this map contains the value, otherwise false.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::copy ( const StlMap< K, V, COMPARATOR > &  source) [inline, virtual]
template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::copy ( const Map< K, V, COMPARATOR > &  source) [inline, virtual]

Copies the content of the source map into this map.Erases all existing data in this map.

Parameters:
sourceThe source object to copy from.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::equals ( const Map< K, V, COMPARATOR > &  source) const [inline, virtual]

Comparison, equality is dependent on the method of determining if the element are equal.

Parameters:
source- Map to compare to this one.
Returns:
true if the Map passed is equal in value to this one.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::equals ( const StlMap< K, V, COMPARATOR > &  source) const [inline, virtual]

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual V& decaf::util::StlMap< K, V, COMPARATOR >::get ( const K &  key) [inline, virtual]

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.

Parameters:
keyThe search key.
Returns:
A reference to the value for the given key.
Exceptions:
NoSuchElementExceptionif the key requests doesn't exist in the Map.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual const V& decaf::util::StlMap< K, V, COMPARATOR >::get ( const K &  key) const [inline, virtual]

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.

Parameters:
keyThe search key.
Returns:
A {const} reference to the value for the given key.
Exceptions:
NoSuchElementExceptionif the key requests doesn't exist in the Map.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::isEmpty ( ) const [inline, virtual]

Returns:
if the Map contains any element or not, TRUE or FALSE

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual std::vector<K> decaf::util::StlMap< K, V, COMPARATOR >::keySet ( ) const [inline, virtual]

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.

Returns:
the entire set of keys in this map as a std::vector.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::lock ( ) [inline, virtual]

Locks the object.

Exceptions:
RuntimeExceptionif an error occurs while locking the object.

Implements decaf::util::concurrent::Synchronizable.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::notify ( ) [inline, virtual]

Signals a waiter on this object that it can now wake up and continue.

Must have this object locked before calling.

Exceptions:
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.
RuntimeExceptionif an error occurs while notifying one of the waiting threads.

Implements decaf::util::concurrent::Synchronizable.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::notifyAll ( ) [inline, virtual]

Signals the waiters on this object that it can now wake up and continue.

Must have this object locked before calling.

Exceptions:
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.
RuntimeExceptionif an error occurs while notifying the waiting threads.

Implements decaf::util::concurrent::Synchronizable.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::put ( const K &  key,
const V &  value 
) [inline, virtual]

Sets the value for the specified key.

Parameters:
keyThe target key.
valueThe value to be set.
Exceptions:
UnsupportedOperationExceptionif this map is unmodifiable.

Implements decaf::util::Map< K, V, COMPARATOR >.

Referenced by decaf::util::StlMap< std::string, cms::Topic * >::putAll().

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::putAll ( const StlMap< K, V, COMPARATOR > &  other) [inline, virtual]
template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::putAll ( const Map< K, V, COMPARATOR > &  other) [inline, virtual]

Stores a copy of the Mappings contained in the other Map in this one.

Parameters:
otherA Map instance whose elements are to all be inserted in this Map.
Exceptions:
UnsupportedOperationExceptionIf the implementing class does not support the putAll operation.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual V decaf::util::StlMap< K, V, COMPARATOR >::remove ( const K &  key) [inline, virtual]

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.

Parameters:
keyThe search key.
Returns:
a copy of the element that was previously mapped to the given key
Exceptions:
NoSuchElementExceptionif this key is not in the Map.
UnsupportedOperationExceptionif this map is unmodifiable.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual int decaf::util::StlMap< K, V, COMPARATOR >::size ( ) const [inline, virtual]

Returns:
The number of elements (key/value pairs) in this map.

Implements decaf::util::Map< K, V, COMPARATOR >.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual bool decaf::util::StlMap< K, V, COMPARATOR >::tryLock ( ) [inline, virtual]

Attempts to Lock the object, if the lock is already held by another thread than this method returns false.

Returns:
true if the lock was acquired, false if it is already held by another thread.
Exceptions:
RuntimeExceptionif an error occurs while locking the object.

Implements decaf::util::concurrent::Synchronizable.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::unlock ( ) [inline, virtual]

Unlocks the object.

Exceptions:
RuntimeExceptionif an error occurs while unlocking the object.

Implements decaf::util::concurrent::Synchronizable.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual std::vector<V> decaf::util::StlMap< K, V, COMPARATOR >::values ( ) const [inline, virtual]

Returns:
the entire set of values in this map as a std::vector.

Implements decaf::util::Map< K, V, COMPARATOR >.

Referenced by decaf::util::StlMap< std::string, cms::Topic * >::values().

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::wait ( ) [inline, virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling.

Exceptions:
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif 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.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::wait ( long long  millisecs,
int  nanos 
) [inline, virtual]

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.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
nanosadditional time in nanoseconds with a range of 0-999999
Exceptions:
IllegalArgumentExceptionif an error occurs or the nanos argument is not in the range of [0-999999]
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif 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.

template<typename K, typename V, typename COMPARATOR = std::less<K>>
virtual void decaf::util::StlMap< K, V, COMPARATOR >::wait ( long long  millisecs) [inline, virtual]

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.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
Exceptions:
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif 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.


The documentation for this class was generated from the following file: