You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/06/01 19:29:16 UTC
svn commit: r543540 - in
/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util: Map.h Queue.h
Set.h
Author: tabish
Date: Fri Jun 1 10:29:16 2007
New Revision: 543540
URL: http://svn.apache.org/viewvc?view=rev&rev=543540
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Building Decaf lib
Added:
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Map.h
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Queue.h
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Set.h
Added: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Map.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Map.h?view=auto&rev=543540
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Map.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Map.h Fri Jun 1 10:29:16 2007
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_MAP_H_
+#define _DECAF_UTIL_MAP_H_
+
+#include <map>
+#include <vector>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Mutex.h>
+
+namespace decaf{
+namespace util{
+
+ /**
+ * 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.
+ */
+ template <typename K, typename V> class Map : public concurrent::Synchronizable
+ {
+ private:
+
+ std::map<K,V> valueMap;
+ concurrent::Mutex mutex;
+
+ public:
+
+ /**
+ * Default constructor - does nothing.
+ */
+ Map(){};
+
+ /**
+ * Copy constructor - copies the content of the given map into this
+ * one.
+ * @param source The source map.
+ */
+ Map( const Map& source ){
+ copy( source );
+ }
+
+ virtual ~Map(){};
+
+ /**
+ * Comparison, equality is dependant on the method of determining
+ * if the element are equal.
+ * @param source - Map to compare to this one.
+ * @returns true if the Map passed is equal in value to this one.
+ */
+ virtual bool equals( const Map& source ) const;
+
+ /**
+ * Copies the content of the source map into this map. Erases
+ * all existing data in this map.
+ * @param source The source object to copy from.
+ */
+ virtual void copy( const Map& source );
+
+ /**
+ * Removes all keys and values from this map.
+ */
+ virtual void clear();
+
+ /**
+ * Indicates whether or this map contains a value for the
+ * given key.
+ * @param key The key to look up.
+ * @return true if this map contains the value, otherwise false.
+ */
+ virtual bool containsKey( const K& key ) 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.
+ * @param value The Value to look up.
+ * @return true if this map contains the value, otherwise false.
+ */
+ virtual bool containsValue( const V& value ) const;
+
+ /**
+ * @return if the Map contains any element or not, TRUE or FALSE
+ */
+ virtual bool isEmpty() const;
+
+ /**
+ * @return The number of elements (key/value pairs) in this map.
+ */
+ virtual std::size_t size() const;
+
+ /**
+ * Gets the value for the specified key.
+ * @param key The search key.
+ * @return The value for the given key.
+ * @throws activemq::exceptions::NoSuchElementException
+ */
+ virtual V getValue( const K& key ) const
+ throw( lang::exceptions::NoSuchElementException );
+
+ /**
+ * Sets the value for the specified key.
+ * @param key The target key.
+ * @param value The value to be set.
+ */
+ virtual void setValue( const K& key, V value );
+
+ /**
+ * Removes the value (key/value pair) for the specified key from
+ * the map.
+ * @param key The search key.
+ */
+ virtual void remove( const K& key );
+
+ /**
+ * @return the entire set of keys in this map as a std::vector.
+ */
+ virtual std::vector<K> getKeys() const;
+
+ /**
+ * @return the entire set of values in this map as a std::vector.
+ */
+ virtual std::vector<V> getValues() const;
+
+ public: // Methods from Synchronizable
+
+ /**
+ * Locks the object.
+ * @throws ActiveMQException
+ */
+ virtual void lock() throw(lang::Exception) {
+ mutex.lock();
+ }
+
+ /**
+ * Unlocks the object.
+ * @throws ActiveMQException
+ */
+ virtual void unlock() throw(lang::Exception) {
+ mutex.unlock();
+ }
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void wait() throw(lang::Exception) {
+ mutex.wait();
+ }
+
+ /**
+ * 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.
+ * @param millisecs the time in millisecsonds to wait, or
+ * WAIT_INIFINITE
+ * @throws ActiveMQException
+ */
+ virtual void wait(unsigned long millisecs)
+ throw(lang::Exception) {
+ mutex.wait(millisecs);
+ }
+
+ /**
+ * Signals a waiter on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notify() throw( lang::Exception ) {
+ mutex.notify();
+ }
+
+ /**
+ * Signals the waiters on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notifyAll() throw( lang::Exception ) {
+ mutex.notifyAll();
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ bool Map<K,V>::equals( const Map& source ) const {
+ return this->valueMap == source.valueMap;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ void Map<K,V>::copy( const Map<K,V>& source ) {
+
+ // Get an iterator to the beginning of the source map.
+ typename std::map<K,V>::const_iterator iter;
+ iter = source.valueMap.begin();
+
+ // Erase the content of this object.
+ clear();
+
+ // Add all of the entries to this map.
+ for( ; iter != source.valueMap.end(); iter++ ){
+ setValue( iter->first, iter->second );
+ }
+
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ void Map<K,V>::clear(){
+ valueMap.clear();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ bool Map<K,V>::containsKey(const K& key) const{
+ typename std::map<K,V>::const_iterator iter;
+ iter = valueMap.find(key);
+ return iter != valueMap.end();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ bool Map<K,V>::containsValue( const V& value ) const {
+
+ if( valueMap.empty() ){
+ return false;
+ }
+
+ typename std::map<K,V>::const_iterator iter = valueMap.begin();
+ for( ; iter != valueMap.end(); ++iter ){
+ if( (*iter).second == value ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ bool Map<K,V>::isEmpty() const{
+ return valueMap.empty();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ std::size_t Map<K,V>::size() const{
+ return valueMap.size();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ V Map<K,V>::getValue( const K& key ) const
+ throw(activemq::exceptions::NoSuchElementException){
+
+ typename std::map<K,V>::const_iterator iter;
+ iter = valueMap.find(key);
+ if( iter == valueMap.end() ){
+ throw activemq::exceptions::NoSuchElementException( __FILE__,
+ __LINE__,
+ "Key does not exist in map" );
+ }
+
+ return iter->second;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ void Map<K,V>::setValue( const K& key, V value ){
+ valueMap[key] = value;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ void Map<K,V>::remove( const K& key ){
+ valueMap.erase(key);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ std::vector<K> Map<K,V>::getKeys() const{
+ std::vector<K> keys(valueMap.size());
+
+ typename std::map<K,V>::const_iterator iter;
+ iter=valueMap.begin();
+ for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
+ keys[ix] = iter->first;
+ }
+
+ return keys;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename K, typename V>
+ std::vector<V> Map<K,V>::getValues() const{
+ std::vector<V> values(valueMap.size());
+
+ typename std::map<K,V>::const_iterator iter;
+ iter=valueMap.begin();
+ for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
+ values[ix] = iter->second;
+ }
+
+ return values;
+ }
+
+}}
+
+#endif /*_DECAF_UTIL_MAP_H_*/
Added: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Queue.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Queue.h?view=auto&rev=543540
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Queue.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Queue.h Fri Jun 1 10:29:16 2007
@@ -0,0 +1,362 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_QUEUE_H
+#define _DECAF_UTIL_QUEUE_H
+
+#include <list>
+#include <vector>
+#include <decaf/util/concurrent/Mutex.h>
+#include <decaf/lang/Exception.h>
+
+namespace decaf{
+namespace util{
+
+ /**
+ * The Queue class accepts messages with an psuh(m) command
+ * where m is the message to be queued. It destructively
+ * returns the message with pop(). pop() returns messages in
+ * the order they were enqueued.
+ *
+ * Queue is implemented with an instance of the STL queue object.
+ * The interface is essentially the same as that of the STL queue
+ * except that the pop method actually reaturns a reference to the
+ * element popped. This frees the app from having to call the
+ * <code>front</code> method before calling pop.
+ *
+ * Queue<string> sq; // make a queue to hold string messages
+ * sq.push(s); // enqueues a message m
+ * string s = sq.pop(); // dequeues a message
+ *
+ * = DESIGN CONSIDERATIONS
+ *
+ * The Queue class inherits from the Synchronizable interface and
+ * provides methods for locking and unlocking this queue as well as
+ * waiting on this queue. In a multi-threaded app this can allow
+ * for multiple threads to be reading from and writing to the same
+ * Queue.
+ *
+ * Clients should consider that in a multiple threaded app it is
+ * possible that items could be placed on the queue faster than
+ * you are taking them off, so protection should be placed in your
+ * polling loop to ensure that you don't get stuck there.
+ */
+
+ template <typename T> class Queue : public concurrent::Synchronizable
+ {
+ public:
+
+ Queue();
+ virtual ~Queue();
+
+ /**
+ * Empties this queue.
+ */
+ void clear();
+
+ /**
+ * Returns a Reference to the element at the head of the queue
+ * @return reference to a queue type object or (safe)
+ */
+ T& front();
+
+ /**
+ * Returns a Reference to the element at the head of the queue
+ * @return reference to a queue type object or (safe)
+ */
+ const T& front() const;
+
+ /**
+ * Returns a Reference to the element at the tail of the queue
+ * @return reference to a queue type object or (safe)
+ */
+ T& back();
+
+ /**
+ * Returns a Reference to the element at the tail of the queue
+ * @return reference to a queue type object or (safe)
+ */
+ const T& back() const;
+
+ /**
+ * Places a new Object at the Tail of the queue
+ * @param t - Queue Object Type reference.
+ */
+ void push( const T &t );
+
+ /**
+ * Places a new Object at the front of the queue
+ * @param t - Queue Object Type reference.
+ */
+ void enqueueFront( const T &t );
+
+ /**
+ * Removes and returns the element that is at the Head of the queue
+ * @return reference to a queue type object or (safe)
+ */
+ T pop();
+
+ /**
+ * Gets the Number of elements currently in the Queue
+ * @return Queue Size
+ */
+ size_t size() const;
+
+ /**
+ * Checks if this Queue is currently empty
+ * @return boolean indicating queue emptiness
+ */
+ bool empty() const;
+
+ /**
+ * @return the all values in this queue as a std::vector.
+ */
+ virtual std::vector<T> toArray() const;
+
+ /**
+ * Reverses the order of the contents of this queue and stores them
+ * in the target queue.
+ * @param target - The target queue that will receive the contents of
+ * this queue in reverse order.
+ */
+ void reverse( Queue<T>& target ) const;
+
+ /**
+ * Locks the object.
+ */
+ virtual void lock() throw( lang::Exception ){
+ mutex.lock();
+ }
+
+ /**
+ * Unlocks the object.
+ */
+ virtual void unlock() throw( lang::Exception ){
+ mutex.unlock();
+ }
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling.
+ */
+ virtual void wait() throw( lang::Exception ){
+ mutex.wait();
+ }
+
+ /**
+ * 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.
+ * @param millisecs time to wait, or WAIT_INIFINITE
+ * @throws ActiveMQException
+ */
+ virtual void wait( unsigned long millisecs )
+ throw( lang::Exception ) {
+
+ mutex.wait(millisecs);
+ }
+
+ /**
+ * Signals a waiter on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ */
+ virtual void notify() throw( lang::Exception ){
+ mutex.notify();
+ }
+
+ /**
+ * Signals the waiters on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ */
+ virtual void notifyAll() throw( lang::Exception ){
+ mutex.notifyAll();
+ }
+
+ public: // Statics
+
+ /**
+ * Fetch a reference to the safe value this object will return
+ * when there is nothing to fetch from the queue.
+ * @return Reference to this Queues safe object
+ */
+ static const T& getSafeValue() { return safe; }
+
+ private:
+
+ // The real queue
+ std::list<T> queue;
+
+ // Object used for sync
+ concurrent::Mutex mutex;
+
+ // Safe value used when pop, front or back are
+ // called and the queue is empty.
+ static T safe;
+
+ };
+
+ //-----{ Static Init }----------------------------------------------------//
+ template <typename T>
+ T Queue<T>::safe;
+
+ //-----{ Retrieve current length of Queue }-------------------------------//
+
+ template <typename T> inline size_t Queue<T>::size() const
+ {
+ return queue.size();
+ }
+
+ //-----{ Retrieve whether Queue is empty or not }-------------------------//
+
+ template <typename T> inline bool Queue<T>::empty() const
+ {
+ return queue.empty();
+ }
+
+ //-----{ Defulat Constructor }--------------------------------------------//
+
+ template <typename T>
+ Queue<T>::Queue()
+ {
+ }
+
+ //-----{ Default Destructor }---------------------------------------------//
+
+ template <typename T> Queue<T>::~Queue()
+ {
+ }
+
+ template <typename T>
+ void Queue<T>::clear()
+ {
+ queue.clear();
+ }
+
+ //-----{ Add Elements to Back of Queue }----------------------------------//
+
+ template <typename T>
+ void Queue<T>::push( const T &t )
+ {
+ queue.push_back( t );
+ }
+
+ template <typename T>
+ void Queue<T>::enqueueFront( const T &t )
+ {
+ queue.push_front( t );
+ }
+
+ //-----{ Remove Elements from Front of Queue }----------------------------//
+
+ template <typename T>
+ T Queue<T>::pop()
+ {
+ if(queue.empty())
+ {
+ return safe;
+ }
+
+ // Pop the element into a temp, since we need to remain locked.
+ // this means getting front and then popping.
+ T temp = queue.front();
+ queue.pop_front();
+
+ return temp;
+ }
+
+ //-----{ Returnreference to element at front of Queue }-------------------//
+
+ template <typename T>
+ T& Queue<T>::front()
+ {
+ if( queue.empty() )
+ {
+ return safe;
+ }
+
+ return queue.front();
+ }
+
+ //-----{ Returnreference to element at front of Queue }-------------------//
+
+ template <typename T>
+ const T& Queue<T>::front() const
+ {
+ if( queue.empty() )
+ {
+ return safe;
+ }
+
+ return queue.front();
+ }
+
+ //-----{ Returnreference to element at back of Queue }--------------------//
+
+ template <typename T>
+ T& Queue<T>::back()
+ {
+ if( queue.empty() )
+ {
+ return safe;
+ }
+
+ return queue.back();
+ }
+
+ //-----{ Returnreference to element at back of Queue }--------------------//
+
+ template <typename T>
+ const T& Queue<T>::back() const
+ {
+ if( queue.empty() )
+ {
+ return safe;
+ }
+
+ return queue.back();
+ }
+
+ template <typename T>
+ void Queue<T>::reverse( Queue<T>& target ) const
+ {
+ typename std::list<T>::const_reverse_iterator iter;
+ iter = queue.rbegin();
+ for( ; iter != queue.rend(); ++iter ) {
+ target.push( *iter );
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ std::vector<T> Queue<T>::toArray() const{
+ std::vector<T> valueArray(queue.size());
+
+ typename std::list<T>::const_iterator iter;
+ iter=queue.begin();
+ for( int ix=0; iter != queue.end(); ++iter, ++ix ){
+ valueArray[ix] = *iter;
+ }
+
+ return valueArray;
+ }
+
+}}
+
+#endif /* _DECAF_UTIL_QUEUE_H */
Added: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Set.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Set.h?view=auto&rev=543540
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Set.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/Set.h Fri Jun 1 10:29:16 2007
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_SET_H_
+#define _DECAF_UTIL_SET_H_
+
+#include <set>
+#include <vector>
+#include <decaf/lang/exceptions/NoSuchElementException.h>
+#include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Mutex.h>
+
+namespace decaf{
+namespace util{
+
+ /**
+ * 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.
+ */
+ template <typename E> class Set : public concurrent::Synchronizable
+ {
+ private:
+
+ std::set<E> values;
+ concurrent::Mutex mutex;
+
+ public:
+
+ /**
+ * Default constructor - does nothing.
+ */
+ Set(){}
+
+ /**
+ * Copy constructor - copies the content of the given set into this
+ * one.
+ * @param source The source set.
+ */
+ Set( const Set& source ){
+ copy( source );
+ }
+
+ virtual ~Set(){}
+
+ /**
+ * Copies the content of the source set into this set. Erases
+ * all existing data in this st.
+ * @param source The source object to copy from.
+ */
+ virtual void copy( const Set& source );
+
+ /**
+ * Removes all values from this set.
+ */
+ virtual void clear();
+
+ /**
+ * Indicates whether or this set contains the given value.
+ * @param value The value to look up.
+ * @return true if this set contains the value, otherwise false.
+ */
+ virtual bool contains( const E& value ) const;
+
+ /**
+ * @return if the set contains any element or not, TRUE or FALSE
+ */
+ virtual bool isEmpty() const;
+
+ /**
+ * @return The number of elements in this set.
+ */
+ virtual std::size_t size() const;
+
+ /**
+ * Adds the given value to the set.
+ * @param value The value to add.
+ */
+ virtual void add( const E& value );
+
+ /**
+ * Removes the value from the set.
+ * @param value The value to be removed.
+ */
+ virtual void remove( const E& value );
+
+ /**
+ * @return the all values in this set as a std::vector.
+ */
+ virtual std::vector<E> toArray() const;
+
+ public: // Methods from Synchronizable
+
+ /**
+ * Locks the object.
+ * @throws ActiveMQException
+ */
+ virtual void lock() throw( lang::Exception ) {
+ mutex.lock();
+ }
+
+ /**
+ * Unlocks the object.
+ * @throws ActiveMQException
+ */
+ virtual void unlock() throw( lang::Exception ) {
+ mutex.unlock();
+ }
+
+ /**
+ * Waits on a signal from this object, which is generated
+ * by a call to Notify. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void wait() throw( lang::Exception ) {
+ mutex.wait();
+ }
+
+ /**
+ * 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.
+ * @param millisecs the time in millisecsonds to wait, or
+ * WAIT_INIFINITE
+ * @throws ActiveMQException
+ */
+ virtual void wait(unsigned long millisecs) throw( lang::Exception ) {
+ mutex.wait(millisecs);
+ }
+
+ /**
+ * Signals a waiter on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notify() throw( lang::Exception ) {
+ mutex.notify();
+ }
+
+ /**
+ * Signals the waiters on this object that it can now wake
+ * up and continue. Must have this object locked before
+ * calling.
+ * @throws ActiveMQException
+ */
+ virtual void notifyAll() throw( lang::Exception ) {
+ mutex.notifyAll();
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ void Set<E>::copy( const Set<E>& source ) {
+
+ // Add all of the entries to this map.
+ values = source.values;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ void Set<E>::clear(){
+ values.clear();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ bool Set<E>::contains(const E& value) const{
+ typename std::set<E>::const_iterator iter;
+ iter = values.find(value);
+ return iter != values.end();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ bool Set<E>::isEmpty() const{
+ return values.empty();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ std::size_t Set<E>::size() const{
+ return values.size();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ void Set<E>::add( const E& value ){
+ values.insert(value);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ void Set<E>::remove( const E& value ){
+ values.erase(value);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ template <typename E>
+ std::vector<E> Set<E>::toArray() const{
+ std::vector<E> valueArray(values.size());
+
+ typename std::set<E>::const_iterator iter;
+ iter=values.begin();
+ for( int ix=0; iter != values.end(); ++iter, ++ix ){
+ valueArray[ix] = *iter;
+ }
+
+ return valueArray;
+ }
+
+}}
+
+#endif /*_DECAF_UTIL_SET_H_*/