activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: add missing virtual dtor, use decaf comparator for Less<>
Date Mon, 16 Sep 2013 21:20:51 GMT
Updated Branches:
  refs/heads/trunk 17673bdfe -> c2ea23827


add missing virtual dtor, use decaf comparator for Less<>

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/c2ea2382
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/c2ea2382
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/c2ea2382

Branch: refs/heads/trunk
Commit: c2ea238278ceb601e713a0863d0c29b0a7a0de8a
Parents: 17673bd
Author: Timothy Bish <tabish121@gmai.com>
Authored: Mon Sep 16 17:20:42 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Mon Sep 16 17:20:42 2013 -0400

----------------------------------------------------------------------
 activemq-cpp/src/main/decaf/util/StlList.h | 235 ++++++++++++------------
 activemq-cpp/src/main/decaf/util/StlMap.h  |  30 ++-
 2 files changed, 128 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/c2ea2382/activemq-cpp/src/main/decaf/util/StlList.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/StlList.h b/activemq-cpp/src/main/decaf/util/StlList.h
index 13a2a38..3b1a181 100644
--- a/activemq-cpp/src/main/decaf/util/StlList.h
+++ b/activemq-cpp/src/main/decaf/util/StlList.h
@@ -54,16 +54,16 @@ namespace util{
 
         private:
 
-            StlListIterator( const StlListIterator& );
-            StlListIterator operator= ( const StlListIterator& );
+            StlListIterator(const StlListIterator&);
+            StlListIterator operator= (const StlListIterator&);
 
         public:
 
-            StlListIterator( typename std::list<E>* list, int index ) :
-                current( list->begin() ), prev( list->end() ), list( list ) {
+            StlListIterator(typename std::list<E>* list, int index) :
+                current(list->begin()), prev(list->end()), list(list) {
 
-                if( index < (int)list->size() ) {
-                    std::advance( this->current, index );
+                if (index < (int) list->size()) {
+                    std::advance(this->current, index);
                 } else {
                     this->current = list->end();
                 }
@@ -72,14 +72,14 @@ namespace util{
             virtual ~StlListIterator() {}
 
             virtual E next() {
-                if( this->current == list->end() ) {
+                if (this->current == list->end()) {
                     throw NoSuchElementException(
                         __FILE__, __LINE__,
-                        "List::Iterator::next - No more elements to return" );
+                        "List::Iterator::next - No more elements to return");
                 }
 
                 this->prev = this->current;
-                return *( this->current++ );
+                return *(this->current++);
             }
 
             virtual bool hasNext() const {
@@ -87,60 +87,58 @@ namespace util{
             }
 
             virtual void remove() {
-                if( this->prev == list->end() ) {
+                if (this->prev == list->end()) {
                     throw lang::exceptions::IllegalStateException(
                         __FILE__, __LINE__,
-                        "List::Iterator::remove - Invalid State to call remove" );
+                        "List::Iterator::remove - Invalid State to call remove");
                 }
 
-                this->list->erase( this->prev );
+                this->list->erase(this->prev);
                 this->prev = this->list->end();
             }
 
-            virtual void add( const E& e ) {
-                this->list->insert( this->current, e );
+            virtual void add(const E& e) {
+                this->list->insert(this->current, e);
             }
 
-            virtual void set( const E& e ) {
-
-                if( this->current == list->end() ) {
-                    this->list->insert( this->current, e );
+            virtual void set(const E& e) {
+                if (this->current == list->end()) {
+                    this->list->insert(this->current, e);
                 } else {
-                    *( this->current ) = e;
+                    *(this->current) = e;
                 }
             }
 
             virtual bool hasPrevious() const {
-                return ( this->current != this->list->begin() );
+                return (this->current != this->list->begin());
             }
 
             virtual E previous() {
-                if( this->current == this->list->begin() ) {
+                if (this->current == this->list->begin()) {
                     throw NoSuchElementException(
                         __FILE__, __LINE__,
                         "List::ListIterator::previous - No Previous element." );
                 }
 
                 typename std::list<E>::const_iterator iter = this->current;
-                return *( iter-- );
+                return *(iter--);
             }
 
             virtual int nextIndex() const {
-                if( this->current == this->list->end() ) {
-                    return (int)this->list->size();
+                if (this->current == this->list->end()) {
+                    return (int) this->list->size();
                 }
 
-                return (int)std::distance( this->list->begin(), this->current );
+                return (int) std::distance(this->list->begin(), this->current);
             }
 
             virtual int previousIndex() const {
-                if( this->current == this->list->begin() ) {
+                if (this->current == this->list->begin()) {
                     return -1;
                 }
 
-                return (int)std::distance( this->list->begin(), this->current )
- 1;
+                return (int) std::distance(this->list->begin(), this->current) -
1;
             }
-
         };
 
         class ConstStlListIterator : public decaf::util::ListIterator<E> {
@@ -152,16 +150,16 @@ namespace util{
 
         private:
 
-            ConstStlListIterator( const ConstStlListIterator& );
-            ConstStlListIterator operator= ( const ConstStlListIterator& );
+            ConstStlListIterator(const ConstStlListIterator&);
+            ConstStlListIterator operator= (const ConstStlListIterator&);
 
         public:
 
-            ConstStlListIterator( const typename std::list<E>* list, int index ) :
-                ListIterator<E>(), current( list->begin() ), prev( list->end()
), list( list ) {
+            ConstStlListIterator(const typename std::list<E>* list, int index) :
+                ListIterator<E>(), current(list->begin()), prev(list->end()),
list( list) {
 
-                if( index < (int)list->size() ) {
-                    std::advance( this->current, index );
+                if (index < (int) list->size()) {
+                    std::advance(this->current, index);
                 } else {
                     this->current = list->end();
                 }
@@ -170,70 +168,70 @@ namespace util{
             virtual ~ConstStlListIterator() {}
 
             virtual E next() {
-                if( this->current == list->end() ) {
+                if (this->current == list->end()) {
                     throw NoSuchElementException(
                         __FILE__, __LINE__,
-                        "List::Iterator::next - No more elements to return" );
+                        "List::Iterator::next - No more elements to return");
                 }
 
                 this->prev = this->current;
-                return *( this->current++ );
+                return *(this->current++);
             }
 
             virtual bool hasNext() const {
-                return ( this->current != list->end() );
+                return (this->current != list->end());
             }
 
             virtual void remove() {
 
                 throw lang::exceptions::UnsupportedOperationException(
                     __FILE__, __LINE__,
-                    "List::ListIterator::remove - Const Iterator." );
+                    "List::ListIterator::remove - Const Iterator.");
             }
 
-            virtual void add( const E& e DECAF_UNUSED ) {
+            virtual void add(const E& e DECAF_UNUSED) {
 
                 throw lang::exceptions::UnsupportedOperationException(
                     __FILE__, __LINE__,
-                    "List::ListIterator::add - Const Iterator." );
+                    "List::ListIterator::add - Const Iterator.");
             }
 
-            virtual void set( const E& e DECAF_UNUSED ) {
+            virtual void set(const E& e DECAF_UNUSED) {
 
                 throw lang::exceptions::UnsupportedOperationException(
                     __FILE__, __LINE__,
-                    "List::ListIterator::set - Const Iterator." );
+                    "List::ListIterator::set - Const Iterator.");
             }
 
             virtual bool hasPrevious() const {
-                return ( this->current != this->list->begin() );
+                return (this->current != this->list->begin());
             }
 
             virtual E previous() {
-                if( this->current == this->list->begin() ) {
+                if (this->current == this->list->begin()) {
                     throw NoSuchElementException(
                         __FILE__, __LINE__,
-                        "List::ListIterator::previous - No Previous element." );
+                        "List::ListIterator::previous - No Previous element.");
                 }
 
                 typename std::list<E>::const_iterator iter = this->current;
-                return *( iter-- );
+                return *(iter--);
             }
 
             virtual int nextIndex() const {
-                if( this->current == this->list->end() ) {
-                    return (int)this->list->size();
+                if (this->current == this->list->end()) {
+                    return (int) this->list->size();
                 }
 
-                return (int)std::distance( this->list->begin(), this->current );
+                return (int) std::distance(this->list->begin(), this->current);
             }
 
             virtual int previousIndex() const {
-                if( this->current == this->list->begin() ) {
+                if (this->current == this->list->begin()) {
                     return -1;
                 }
 
-                return (int)std::distance( this->list->begin(), this->current )
- 1;
+                return (int) std::distance(this->list->begin(), this->current) -
1;
             }
         };
 
@@ -249,8 +247,8 @@ namespace util{
          * one.
          * @param source The source set.
          */
-        StlList( const StlList& source ) : AbstractList<E>(), values() {
-            copy( source );
+        StlList(const StlList& source) : AbstractList<E>(), values() {
+            copy(source);
         }
 
         /**
@@ -258,18 +256,20 @@ namespace util{
          * one.
          * @param source The source set.
          */
-        StlList( const Collection<E>& source ) : AbstractList<E>(), values()
{
-            AbstractList<E>::copy( source );
+        StlList(const Collection<E>& source) : AbstractList<E>(), values()
{
+            AbstractList<E>::copy(source);
         }
 
+        virtual ~StlList() {}
+
         /**
          * {@inheritDoc}
          */
-        virtual bool equals( const Collection<E>& collection ) const {
+        virtual bool equals(const Collection<E>& collection) const {
 
-            const StlList<E>* listptr = dynamic_cast<const StlList<E>*>(
&collection );
-            if( listptr == NULL ) {
-                return AbstractList<E>::equals( collection );
+            const StlList<E>* listptr = dynamic_cast<const StlList<E>*>(&collection);
+            if (listptr == NULL) {
+                return AbstractList<E>::equals(collection);
             }
 
             return this->values == listptr->values;
@@ -278,11 +278,11 @@ namespace util{
         /**
          * {@inheritDoc}
          */
-        virtual void copy( const Collection<E>& collection ) {
+        virtual void copy(const Collection<E>& collection) {
 
-            const StlList<E>* listptr = dynamic_cast<const StlList<E>*>(
&collection );
-            if( listptr == NULL ) {
-                AbstractList<E>::copy( collection );
+            const StlList<E>* listptr = dynamic_cast<const StlList<E>*>(&collection);
+            if (listptr == NULL) {
+                AbstractList<E>::copy(collection);
                 return;
             }
 
@@ -294,44 +294,44 @@ namespace util{
          * {@inheritDoc}
          */
         virtual Iterator<E>* iterator() {
-            return new StlListIterator( &values, 0 );
+            return new StlListIterator(&values, 0);
         }
         virtual Iterator<E>* iterator() const {
-            return new ConstStlListIterator( &values, 0 );
+            return new ConstStlListIterator(&values, 0);
         }
 
         /**
          * {@inheritDoc}
          */
         virtual ListIterator<E>* listIterator() {
-            return new StlListIterator( &values, 0 );
+            return new StlListIterator(&values, 0);
         }
         virtual ListIterator<E>* listIterator() const {
-            return new ConstStlListIterator( &values, 0 );
+            return new ConstStlListIterator(&values, 0);
         }
 
         /**
          * {@inheritDoc}
          */
-        virtual ListIterator<E>* listIterator( int index ) {
+        virtual ListIterator<E>* listIterator(int index) {
 
-            if( index < 0 || index > this->size() ) {
+            if (index < 0 || index > this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::listIterator - Index greater than size() or negative" );
+                    "List::listIterator - Index greater than size() or negative");
             }
 
-            return new StlListIterator( &values, index );
+            return new StlListIterator(&values, index);
         }
-        virtual ListIterator<E>* listIterator( int index ) const {
+        virtual ListIterator<E>* listIterator(int index) const {
 
-            if( index < 0 || index > this->size() ) {
+            if (index < 0 || index > this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::listIterator - Index greater than size() or negative" );
+                    "List::listIterator - Index greater than size() or negative");
             }
 
-            return new ConstStlListIterator( &values, index );
+            return new ConstStlListIterator(&values, index);
         }
 
         /**
@@ -358,7 +358,7 @@ namespace util{
         /**
          * {@inheritDoc}
          */
-        virtual E get( int index ) const {
+        virtual E get(int index) const {
 
             if( index < 0 || index >= this->size() ) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
@@ -375,56 +375,56 @@ namespace util{
         /**
          * {@inheritDoc}
          */
-        virtual E set( int index, const E& element ) {
+        virtual E set(int index, const E& element) {
 
-            if( index < 0 || index >= this->size() ) {
+            if (index < 0 || index >= this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::get - Index greater than size() or negative" );
+                    "List::get - Index greater than size() or negative");
             }
 
             // Advance from begin and return the value at that location
             // after setting the value to the new value.
             typename std::list<E>::iterator iter = this->values.begin();
-            std::advance( iter, index );
+            std::advance(iter, index);
             E oldValue = *iter;
             *iter = element;
 
             return oldValue;
         }
 
-        virtual void add( int index, const E& element ) {
+        virtual void add(int index, const E& element) {
 
-            if( index < 0 || index > this->size() ) {
+            if (index < 0 || index > this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::add - Index greater than size()" );
+                    "List::add - Index greater than size()");
             }
 
             // Advance from begin and insert the value at that location
             typename std::list<E>::iterator iter = this->values.begin();
-            std::advance( iter, index );
-            this->values.insert( iter, element );
+            std::advance(iter, index);
+            this->values.insert(iter, element);
         }
 
-        virtual bool add( const E& value ) {
-            values.insert( values.end(), value );
+        virtual bool add(const E& value) {
+            values.insert(values.end(), value);
             return true;
         }
 
-        virtual bool addAll( const Collection<E>& collection ) {
+        virtual bool addAll(const Collection<E>& collection) {
 
-            if( collection.isEmpty() ) {
+            if (collection.isEmpty()) {
                 return false;
             }
 
             std::vector<E> array = collection.toArray();
             typename std::vector<E>::const_iterator vecIter = array.begin();
 
-            std::auto_ptr< ListIterator<E> > iter( this->listIterator( (int)this->values.size()
) );
+            std::auto_ptr<ListIterator<E> > iter(this->listIterator((int)
this->values.size()));
 
-            while( vecIter != array.end() ) {
-                iter->add( *( vecIter++) );
+            while (vecIter != array.end()) {
+                iter->add(*(vecIter++));
             }
 
             return true;
@@ -433,25 +433,25 @@ namespace util{
         /**
          * {@inheritDoc}
          */
-        virtual bool addAll( int index, const Collection<E>& collection ) {
+        virtual bool addAll(int index, const Collection<E>& collection) {
 
-            if( index < 0 || index > this->size() ) {
+            if (index < 0 || index > this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::addAll - Index greater than size()" );
+                    "List::addAll - Index greater than size()");
             }
 
-            if( collection.isEmpty() ) {
+            if (collection.isEmpty()) {
                 return false;
             }
 
             std::vector<E> array = collection.toArray();
             typename std::vector<E>::const_iterator vecIter = array.begin();
 
-            std::auto_ptr< ListIterator<E> > iter( this->listIterator( index
) );
+            std::auto_ptr<ListIterator<E> > iter(this->listIterator(index));
 
-            while( vecIter != array.end() ) {
-                iter->add( *( vecIter++) );
+            while (vecIter != array.end()) {
+                iter->add(*(vecIter++));
             }
 
             return true;
@@ -460,61 +460,60 @@ namespace util{
         /**
          * {@inheritDoc}
          */
-        virtual bool remove( const E& value ) {
-
+        virtual bool remove(const E& value) {
             int origSize = this->size();
-            this->values.remove( value );
+            this->values.remove(value);
             return origSize != this->size();
         }
 
         /**
          * {@inheritDoc}
          */
-        virtual E removeAt( int index ) {
+        virtual E removeAt(int index) {
 
-            if( index < 0 || index >= this->size() ) {
+            if (index < 0 || index >= this->size()) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
                     __FILE__, __LINE__,
-                    "List::removeAt - Index greater than size() or negative" );
+                    "List::removeAt - Index greater than size() or negative");
             }
 
             // Advance from begin and insert the value at that location
             typename std::list<E>::iterator iter = this->values.begin();
-            std::advance( iter, index );
+            std::advance(iter, index);
             E oldValue = *iter;
-            this->values.erase( iter );
+            this->values.erase(iter);
 
             return oldValue;
         }
 
-        virtual int indexOf( const E& value ) const {
+        virtual int indexOf(const E& value) const {
 
             typename std::list<E>::const_iterator iter;
-            iter = std::find( values.begin(), values.end(), value );
+            iter = std::find(values.begin(), values.end(), value);
 
-            if( iter == values.end() ) {
+            if (iter == values.end()) {
                 return -1;
             }
 
-            return (int)std::distance( values.begin(), iter );
+            return (int) std::distance(values.begin(), iter);
         }
 
-        virtual int lastIndexOf( const E& value ) const {
+        virtual int lastIndexOf(const E& value) const {
 
             typename std::list<E>::const_reverse_iterator iter;
-            iter = std::find( values.rbegin(), values.rend(), value );
+            iter = std::find(values.rbegin(), values.rend(), value);
 
-            if( iter == values.rend() ) {
+            if (iter == values.rend()) {
                 return -1;
             }
 
             // Now reverse the result to get the last index
-            return (int)( this->size() - std::distance( values.rbegin(), iter ) - 1 );
+            return (int) (this->size() - std::distance(values.rbegin(), iter) - 1);
         }
 
-        virtual bool contains( const E& value ) const {
+        virtual bool contains(const E& value) const {
             typename std::list<E>::const_iterator iter;
-            iter = std::find( values.begin(), values.end(), value );
+            iter = std::find(values.begin(), values.end(), value);
             return iter != values.end();
         }
 

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/c2ea2382/activemq-cpp/src/main/decaf/util/StlMap.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/StlMap.h b/activemq-cpp/src/main/decaf/util/StlMap.h
index 93c80c6..bc606a6 100644
--- a/activemq-cpp/src/main/decaf/util/StlMap.h
+++ b/activemq-cpp/src/main/decaf/util/StlMap.h
@@ -28,6 +28,7 @@
 #include <decaf/util/AbstractCollection.h>
 #include <decaf/util/concurrent/Synchronizable.h>
 #include <decaf/util/concurrent/Mutex.h>
+#include <decaf/util/comparators/Less.h>
 #include <decaf/util/Map.h>
 #include <decaf/util/Collection.h>
 #include <decaf/util/Set.h>
@@ -43,7 +44,7 @@ namespace util{
      *
      * @since 1.0
      */
-    template <typename K, typename V, typename COMPARATOR = std::less<K> >
+    template <typename K, typename V, typename COMPARATOR = decaf::util::comparators::Less<K>
>
     class StlMap : public Map<K, V> {
     private:
 
@@ -129,8 +130,7 @@ namespace util{
 
         public:
 
-            EntryIterator(StlMap* parent) : AbstractMapIterator(parent) {
-            }
+            EntryIterator(StlMap* parent) : AbstractMapIterator(parent) {}
 
             virtual ~EntryIterator() {}
 
@@ -156,8 +156,7 @@ namespace util{
 
         public:
 
-            KeyIterator(StlMap* parent) : AbstractMapIterator(parent) {
-            }
+            KeyIterator(StlMap* parent) : AbstractMapIterator(parent) {}
 
             virtual ~KeyIterator() {}
 
@@ -264,8 +263,7 @@ namespace util{
 
         public:
 
-            ConstEntryIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {
-            }
+            ConstEntryIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}
 
             virtual ~ConstEntryIterator() {}
 
@@ -320,8 +318,7 @@ namespace util{
 
         public:
 
-            ConstValueIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {
-            }
+            ConstValueIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}
 
             virtual ~ConstValueIterator() {}
 
@@ -355,8 +352,7 @@ namespace util{
 
         public:
 
-            StlMapEntrySet(StlMap* parent) : AbstractSet< MapEntry<K,V> >(),
associatedMap(parent) {
-            }
+            StlMapEntrySet(StlMap* parent) : AbstractSet< MapEntry<K,V> >(),
associatedMap(parent) {}
 
             virtual ~StlMapEntrySet() {}
 
@@ -459,8 +455,7 @@ namespace util{
 
         public:
 
-            StlMapKeySet(StlMap* parent) : AbstractSet<K>(), associatedMap(parent)
{
-            }
+            StlMapKeySet(StlMap* parent) : AbstractSet<K>(), associatedMap(parent)
{}
 
             virtual ~StlMapKeySet() {}
 
@@ -505,8 +500,7 @@ namespace util{
 
         public:
 
-            ConstStlMapKeySet(const StlMap* parent) : AbstractSet<K>(), associatedMap(parent)
{
-            }
+            ConstStlMapKeySet(const StlMap* parent) : AbstractSet<K>(), associatedMap(parent)
{}
 
             virtual ~ConstStlMapKeySet() {}
 
@@ -552,8 +546,7 @@ namespace util{
 
         public:
 
-            StlMapValueCollection(StlMap* parent) : AbstractCollection<V>(), associatedMap(parent)
{
-            }
+            StlMapValueCollection(StlMap* parent) : AbstractCollection<V>(), associatedMap(parent)
{}
 
             virtual ~StlMapValueCollection() {}
 
@@ -590,8 +583,7 @@ namespace util{
 
         public:
 
-            ConstStlMapValueCollection(const StlMap* parent) : AbstractCollection<V>(),
associatedMap(parent) {
-            }
+            ConstStlMapValueCollection(const StlMap* parent) : AbstractCollection<V>(),
associatedMap(parent) {}
 
             virtual ~ConstStlMapValueCollection() {}
 


Mime
View raw message