activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: More cleanup work and a new Equality comparitor.
Date Wed, 18 Sep 2013 22:36:40 GMT
Updated Branches:
  refs/heads/trunk 3b2f87e1d -> 8c0f341a4


More cleanup work and a new Equality comparitor. 

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

Branch: refs/heads/trunk
Commit: 8c0f341a49f0b67e1f951bfd8fe72708595d18ca
Parents: 3b2f87e
Author: Timothy Bish <tabish121@gmai.com>
Authored: Wed Sep 18 18:36:32 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Wed Sep 18 18:36:32 2013 -0400

----------------------------------------------------------------------
 activemq-cpp/src/main/Makefile.am               |   2 +
 .../activemq/commands/ActiveMQTempDestination.h |  19 ++-
 activemq-cpp/src/main/decaf/util/ArrayList.h    | 168 +++++++++----------
 activemq-cpp/src/main/decaf/util/HashMap.h      |   8 +-
 activemq-cpp/src/main/decaf/util/HashSet.h      |  23 +--
 .../src/main/decaf/util/comparators/Equals.cpp  |  18 ++
 .../src/main/decaf/util/comparators/Equals.h    |  94 +++++++++++
 .../src/main/decaf/util/comparators/Less.h      |  12 +-
 8 files changed, 226 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/Makefile.am
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/Makefile.am b/activemq-cpp/src/main/Makefile.am
index 5d117aa..d6ad66e 100644
--- a/activemq-cpp/src/main/Makefile.am
+++ b/activemq-cpp/src/main/Makefile.am
@@ -582,6 +582,7 @@ cc_sources = \
     decaf/util/Timer.cpp \
     decaf/util/TimerTask.cpp \
     decaf/util/UUID.cpp \
+    decaf/util/comparators/Equals.cpp \
     decaf/util/comparators/Less.cpp \
     decaf/util/concurrent/AbstractExecutorService.cpp \
     decaf/util/concurrent/BlockingQueue.cpp \
@@ -1241,6 +1242,7 @@ h_sources = \
     decaf/util/Timer.h \
     decaf/util/TimerTask.h \
     decaf/util/UUID.h \
+    decaf/util/comparators/Equals.h \
     decaf/util/comparators/Less.h \
     decaf/util/concurrent/AbstractExecutorService.h \
     decaf/util/concurrent/BlockingQueue.h \

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/activemq/commands/ActiveMQTempDestination.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/commands/ActiveMQTempDestination.h b/activemq-cpp/src/main/activemq/commands/ActiveMQTempDestination.h
index d639749..99b9294 100644
--- a/activemq-cpp/src/main/activemq/commands/ActiveMQTempDestination.h
+++ b/activemq-cpp/src/main/activemq/commands/ActiveMQTempDestination.h
@@ -32,7 +32,8 @@ namespace core{
 namespace commands{
 
     class AMQCPP_API ActiveMQTempDestination : public ActiveMQDestination,
-                                               public cms::Closeable {
+                                               public cms::Closeable,
+                                               public decaf::lang::Comparable<ActiveMQTempDestination>
{
     protected:
 
         /**
@@ -79,6 +80,22 @@ namespace commands{
             return ActiveMQDestination::equals(value);
         }
 
+        virtual int compareTo(const ActiveMQTempDestination& value) const {
+            return ActiveMQDestination::compareTo(value);
+        }
+
+        virtual bool equals(const ActiveMQTempDestination& value) const {
+            return ActiveMQDestination::equals(&value);
+        }
+
+        virtual bool operator==(const ActiveMQTempDestination& value) const {
+            return ActiveMQDestination::equals(&value);
+        }
+
+        virtual bool operator<(const ActiveMQTempDestination& value) const {
+            return ActiveMQDestination::compareTo(value) < 0;
+        }
+
         virtual void close();
 
         virtual void setPhysicalName(const std::string& physicalName);

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/ArrayList.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/ArrayList.h b/activemq-cpp/src/main/decaf/util/ArrayList.h
index 98f096a..c3a1878 100644
--- a/activemq-cpp/src/main/decaf/util/ArrayList.h
+++ b/activemq-cpp/src/main/decaf/util/ArrayList.h
@@ -95,15 +95,15 @@ namespace util {
 
     public:
 
-        ArrayList<E>& operator= ( const ArrayList<E>& list ) {
+        ArrayList<E>& operator= (const ArrayList<E>& list) {
             this->clear();
             this->addAll( list );
             return *this;
         }
 
-        ArrayList<E>& operator= ( const Collection<E>& collection ) {
+        ArrayList<E>& operator= (const Collection<E>& collection) {
             this->clear();
-            this->addAll( 0, collection );
+            this->addAll(0, collection);
             return *this;
         }
 
@@ -126,17 +126,17 @@ namespace util {
          * @param minimumCapacity
          *      The desired minimum capacity for this ArrayList.
          */
-        void ensureCapacity( int minimumCapacity ) {
+        void ensureCapacity(int minimumCapacity) {
 
-            if( minimumCapacity < 0 || this->capacity >= minimumCapacity ) {
+            if (minimumCapacity < 0 || this->capacity >= minimumCapacity) {
                 return;
             }
 
             int newCapacity = minimumCapacity == 0 ? 10 : minimumCapacity;
 
             E* newElements = new E[newCapacity];
-            if( this->curSize > 0 ) {
-                decaf::lang::System::arraycopy( this->elements, this->head, newElements,
0, this->curSize );
+            if (this->curSize > 0) {
+                decaf::lang::System::arraycopy(this->elements, this->head, newElements,
0, this->curSize);
             }
             delete [] this->elements;
             this->elements = newElements;
@@ -150,13 +150,13 @@ namespace util {
          */
         void trimToSize() {
 
-            if( this->curSize < this->capacity ) {
+            if (this->curSize < this->capacity) {
 
                 int newCapacity = this->curSize == 0 ? 10 : this->curSize;
 
                 E* newElements = new E[newCapacity];
-                if( this->curSize > 0 ) {
-                    System::arraycopy( this->elements, 0, newElements, 0, this->curSize
);
+                if (this->curSize > 0) {
+                    System::arraycopy(this->elements, 0, newElements, 0, this->curSize);
                 }
 
                 delete [] this->elements;
@@ -185,12 +185,11 @@ namespace util {
             return this->curSize;
         }
 
-        virtual E set( int index, const E& element ) {
+        virtual E set(int index, const E& element) {
 
-            if( index < 0 || index >= this->curSize ) {
+            if (index < 0 || index >= this->curSize) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "List::get - Index greater than size() or negative" );
+                    __FILE__, __LINE__, "Index greater than size() or negative");
             }
 
             E oldValue = this->elements[index];
@@ -199,40 +198,38 @@ namespace util {
             return oldValue;
         }
 
-        virtual E get( int index ) const {
+        virtual E get(int index) const {
 
-            if( index < 0 || index >= this->curSize ) {
+            if (index < 0 || index >= this->curSize) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "List::get - Index greater than size() or negative" );
+                    __FILE__, __LINE__, "Index greater than size() or negative");
             }
 
             return this->elements[index];
         }
 
-        virtual bool add( const E& value ) {
+        virtual bool add(const E& value) {
 
-            this->expandEnd( 1 );
+            this->expandEnd(1);
             this->elements[this->curSize++] = value;
             AbstractList<E>::modCount++;
 
             return true;
         }
 
-        virtual void add( int index, const E& element ) {
+        virtual void add(int index, const E& element) {
 
-            if( index < 0 || index > this->curSize ) {
+            if (index < 0 || index > this->curSize) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "Index was negative or greater than size()" );
+                    __FILE__, __LINE__, "Index was negative or greater than size()");
             }
 
-            if( index == 0 ) {
-                this->expandFront( 1 );
-            } else if( index == this->curSize ) {
-                this->expandEnd( 1 );
+            if (index == 0) {
+                this->expandFront(1);
+            } else if (index == this->curSize) {
+                this->expandEnd(1);
             } else {
-                this->expandMiddle( index, 1 );
+                this->expandMiddle(index, 1);
             }
 
             this->elements[index] = element;
@@ -240,18 +237,18 @@ namespace util {
             AbstractList<E>::modCount++;
         }
 
-        virtual bool addAll( const Collection<E>& collection ) {
+        virtual bool addAll(const Collection<E>& collection) {
 
             int csize = collection.size();
-            if( csize == 0 ) {
+            if (csize == 0) {
                 return false;
             }
 
             std::vector<E> array = collection.toArray();
 
-            this->expandEnd( csize );
+            this->expandEnd(csize);
 
-            for( int i = 0; i < csize; ++i ) {
+            for (int i = 0; i < csize; ++i) {
                 this->elements[this->curSize++] = array[i];
             }
 
@@ -260,30 +257,29 @@ namespace util {
             return true;
         }
 
-        virtual bool addAll( int index, const Collection<E>& collection ) {
+        virtual bool addAll(int index, const Collection<E>& collection) {
 
-            if( index < 0 || index > this->curSize ) {
+            if(index < 0 || index > this->curSize) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "List::addAll - Index greater than size()" );
+                    __FILE__, __LINE__, "Index greater than size()");
             }
 
             int csize = collection.size();
-            if( csize == 0 ) {
+            if (csize == 0) {
                 return false;
             }
 
             std::vector<E> array = collection.toArray();
 
-            if( index == 0 ) {
-                this->expandFront( csize );
-            } else if( index == this->curSize ) {
-                this->expandEnd( csize );
+            if (index == 0) {
+                this->expandFront(csize);
+            } else if (index == this->curSize) {
+                this->expandEnd(csize);
             } else {
-                this->expandMiddle( index, csize );
+                this->expandMiddle(index, csize);
             }
 
-            for( int i = 0; i < csize; ++i, ++this->curSize ) {
+            for (int i = 0; i < csize; ++i, ++this->curSize) {
                 this->elements[index++] = array[i];
             }
 
@@ -292,31 +288,30 @@ namespace util {
             return true;
         }
 
-        virtual bool remove( const E& value ) {
+        virtual bool remove(const E& value) {
 
-            int result = indexOf( value );
-            if( result != -1 ) {
-                this->removeAt( result );
+            int result = indexOf(value);
+            if (result != -1) {
+                this->removeAt(result);
                 return true;
             }
 
             return false;
         }
 
-        virtual E removeAt( int index ) {
+        virtual E removeAt(int index) {
 
-            if( index < 0 || index >= this->curSize ) {
+            if (index < 0 || index >= this->curSize) {
                 throw decaf::lang::exceptions::IndexOutOfBoundsException(
-                        __FILE__, __LINE__,
-                        "List::removeAt - Index greater than size() or negative" );
+                    __FILE__, __LINE__, "Index greater than size() or negative");
             }
 
             E old = this->elements[index];
 
-            System::arraycopy( this->elements, 0, this->elements, 0, index );
+            System::arraycopy(this->elements, 0, this->elements, 0, index);
 
-            if( this->curSize > index ) {
-                System::arraycopy( this->elements, index + 1, this->elements, index,
this->curSize - index - 1 );
+            if (this->curSize > index) {
+                System::arraycopy(this->elements, index + 1, this->elements, index,
this->curSize - index - 1);
             }
 
             this->elements[--this->curSize] = E();
@@ -325,14 +320,14 @@ namespace util {
             return old;
         }
 
-        virtual bool contains( const E& value ) const {
-            return this->indexOf( value ) != -1;
+        virtual bool contains(const E& value) const {
+            return this->indexOf(value) != -1;
         }
 
-        virtual int indexOf( const E& value ) const {
+        virtual int indexOf(const E& value) const {
 
-            for( int i = 0; i < this->curSize; ++i ) {
-                if( this->elements[i] == value ) {
+            for (int i = 0; i < this->curSize; ++i) {
+                if (this->elements[i] == value) {
                     return i;
                 }
             }
@@ -340,10 +335,10 @@ namespace util {
             return -1;
         }
 
-        virtual int lastIndexOf( const E& value ) const {
+        virtual int lastIndexOf(const E& value) const {
 
-            for( int i = this->curSize - 1; i >= 0; --i ) {
-                if( this->elements[i] == value ) {
+            for (int i = this->curSize - 1; i >= 0; --i) {
+                if (this->elements[i] == value) {
                     return i;
                 }
             }
@@ -355,8 +350,8 @@ namespace util {
 
             std::vector<E> result;
 
-            for( int i = 0; i < this->curSize; ++i ) {
-                result.push_back( this->elements[i] );
+            for (int i = 0; i < this->curSize; ++i) {
+                result.push_back(this->elements[i]);
             }
 
             return result;
@@ -366,82 +361,81 @@ namespace util {
 
             std::string result;
 
-            result.append( "decaf::util::ArrayList [  size = " );
-            result.append( decaf::lang::Integer::toString( this->curSize ) );
-            result.append( " ]");
+            result.append("decaf::util::ArrayList [ size = ");
+            result.append(decaf::lang::Integer::toString(this->curSize));
+            result.append(" ]");
 
             return result;
         }
 
     private:
 
-        void expandFront( int amount ) {
+        void expandFront(int amount) {
 
-            if( amount == 0 ) {
+            if (amount == 0) {
                 return;
             }
 
             E* previous = this->elements;
 
-            if( amount > this->capacity - this->curSize ) {
+            if (amount > this->capacity - this->curSize) {
                 this->capacity = this->capacity + amount + 11;
                 this->elements = new E[this->capacity];
             }
 
-            if( this->curSize > 0 ) {
-                System::arraycopy( previous, 0, this->elements, amount, this->curSize
);
+            if (this->curSize > 0) {
+                System::arraycopy(previous, 0, this->elements, amount, this->curSize);
             }
 
-            if( previous != this->elements ) {
+            if (previous != this->elements) {
                 delete [] previous;
             }
         }
 
-        void expandEnd( int amount ) {
+        void expandEnd(int amount) {
 
-            if( amount == 0 ) {
+            if (amount == 0) {
                 return;
             }
 
             E* previous = this->elements;
 
-            if( amount > this->capacity - this->curSize ) {
+            if (amount > this->capacity - this->curSize) {
                 this->capacity = this->capacity + amount + 11;
                 this->elements = new E[this->capacity];
                 System::arraycopy( previous, 0, this->elements, 0, this->curSize );
             }
 
-            if( previous != this->elements ) {
+            if(previous != this->elements) {
                 delete [] previous;
             }
         }
 
-        void expandMiddle( int index, int amount ) {
+        void expandMiddle(int index, int amount) {
 
-            if( amount == 0 ) {
+            if (amount == 0) {
                 return;
             }
 
             E* previous = this->elements;
 
-            if( amount > this->capacity - this->curSize ) {
+            if (amount > this->capacity - this->curSize) {
                 this->capacity = this->capacity + amount + 11;
                 this->elements = new E[this->capacity];
             }
 
-            if( this->curSize > 0 ) {
-                System::arraycopy( previous, 0, this->elements, 0, index );
+            if (this->curSize > 0) {
+                System::arraycopy(previous, 0, this->elements, 0, index);
             }
 
-            if( this->curSize > index ) {
-                System::arraycopy( previous, index, this->elements, index + amount, this->curSize
- index );
+            if (this->curSize > index) {
+                System::arraycopy(previous, index, this->elements, index + amount, this->curSize
- index);
             }
 
-            if( previous != this->elements ) {
+            if (previous != this->elements) {
                 delete [] previous;
             }
         }
-
     };
 
 }}

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/HashMap.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/HashMap.h b/activemq-cpp/src/main/decaf/util/HashMap.h
index 2f85e2d..7b25db1 100644
--- a/activemq-cpp/src/main/decaf/util/HashMap.h
+++ b/activemq-cpp/src/main/decaf/util/HashMap.h
@@ -392,7 +392,7 @@ namespace util {
 
             virtual void remove() {
                 throw lang::exceptions::UnsupportedOperationException(
-                    __FILE__, __LINE__, "Cannot write to a const Iterator." );
+                    __FILE__, __LINE__, "Cannot write to a const Iterator.");
             }
         };
 
@@ -420,7 +420,7 @@ namespace util {
 
             virtual void remove() {
                 throw lang::exceptions::UnsupportedOperationException(
-                    __FILE__, __LINE__, "Cannot write to a const Iterator." );
+                    __FILE__, __LINE__, "Cannot write to a const Iterator.");
             }
         };
 
@@ -448,7 +448,7 @@ namespace util {
 
             virtual void remove() {
                 throw lang::exceptions::UnsupportedOperationException(
-                    __FILE__, __LINE__, "Cannot write to a const Iterator." );
+                    __FILE__, __LINE__, "Cannot write to a const Iterator.");
             }
         };
 
@@ -557,7 +557,7 @@ namespace util {
             }
         };
 
-        protected:
+    protected:
 
         class HashMapKeySet : public AbstractSet<K> {
         private:

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/HashSet.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/HashSet.h b/activemq-cpp/src/main/decaf/util/HashSet.h
index e5a06c7..cd9cdec 100644
--- a/activemq-cpp/src/main/decaf/util/HashSet.h
+++ b/activemq-cpp/src/main/decaf/util/HashSet.h
@@ -78,8 +78,7 @@ namespace util {
          * Constructs a new, empty set; the backing HashMap instance has default initial
          * capacity (16) and load factor (0.75).
          */
-        HashSet() : AbstractSet<E>(), backingMap(new HashMap<E, Set<E>*, HASHCODE>())
{
-        }
+        HashSet() : AbstractSet<E>(), backingMap(new HashMap<E, Set<E>*, HASHCODE>())
{}
 
         /**
          * Constructs a new, empty set; the backing HashMap instance has the specified initial
@@ -88,8 +87,7 @@ namespace util {
          * @param capacity
          *      The initial capacity of this HashSet.
          */
-        HashSet(int capacity) : AbstractSet<E>(), backingMap(new HashMap<E, Set<E>*,
HASHCODE>(capacity)) {
-        }
+        HashSet(int capacity) : AbstractSet<E>(), backingMap(new HashMap<E, Set<E>*,
HASHCODE>(capacity)) {}
 
         /**
          * Constructs a new instance of {@code HashSet} with the specified capacity
@@ -180,23 +178,6 @@ namespace util {
         }
 
         /**
-         * Returns a new {@code HashSet} with the same elements and size as this
-         * {@code HashSet}.
-         *
-         * @return a shallow copy of this {@code HashSet}.
-         * @see java.lang.Cloneable
-         */
-//        virtual Object clone() {
-//            try {
-//                HashSet<E> clone = (HashSet<E>) super.clone();
-//                clone.backingMap = (HashMap<E, HashSet<E>>) backingMap.clone();
-//                return clone;
-//            } catch (CloneNotSupportedException e) {
-//                return null;
-//            }
-//        }
-
-        /**
          * Searches this {@code HashSet} for the specified object.
          *
          * @param object

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/comparators/Equals.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/comparators/Equals.cpp b/activemq-cpp/src/main/decaf/util/comparators/Equals.cpp
new file mode 100644
index 0000000..2bc18eb
--- /dev/null
+++ b/activemq-cpp/src/main/decaf/util/comparators/Equals.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
+
+#include "Equals.h"

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/comparators/Equals.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/comparators/Equals.h b/activemq-cpp/src/main/decaf/util/comparators/Equals.h
new file mode 100644
index 0000000..86c469d
--- /dev/null
+++ b/activemq-cpp/src/main/decaf/util/comparators/Equals.h
@@ -0,0 +1,94 @@
+/*
+ * 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_COMPARATORS_EQUALS_H_
+#define _DECAF_UTIL_COMPARATORS_EQUALS_H_
+
+#include <decaf/util/Comparator.h>
+
+#include <decaf/lang/Pointer.h>
+
+namespace decaf {
+namespace util {
+namespace comparators {
+
+    /**
+     * Equality comparator that utilizes the default equality comparison expression == to
+     * determine if two values are considered equal.  Can be used in Collection classes as
+     * a means of comparing objects.
+     */
+    template< typename E >
+    class Equals : public decaf::util::Comparator<E> {
+    public:
+
+        Equals() {}
+        virtual ~Equals() {}
+
+        virtual bool operator()(const E& left, const E& right) const {
+            return left == right;
+        }
+
+        virtual int compare(const E& o1, const E& o2) const {
+
+            if (o1 == o2) {
+                return 0;
+            }
+
+            if (o1 < o2) {
+                return -1;
+            }
+
+            return 1;
+        }
+
+    };
+
+    template< typename E >
+    class Equals< decaf::lang::Pointer<E> > : public decaf::util::Comparator<decaf::lang::Pointer<E>
> {
+    public:
+
+        Equals() {}
+        virtual ~Equals() {}
+
+        virtual bool operator()(const decaf::lang::Pointer<E>& left, const decaf::lang::Pointer<E>&
right) const {
+            if (left != NULL && right != NULL) {
+                return left->equals(*right);
+            } else if (left == NULL && right == NULL) {
+                return true;
+            }
+
+            return false;
+        }
+
+        virtual int compare(const decaf::lang::Pointer<E>& o1, const decaf::lang::Pointer<E>&
o2) const {
+            if (o1 != NULL && o2 != NULL) {
+                return o1->compareTo(*o2);
+            }
+
+            if (o1.get() > o2.get()) {
+                return 1;
+            } else if (o1.get() < o2.get()) {
+                return -1;
+            }
+
+            return 0;
+        }
+
+    };
+
+}}}
+
+#endif /* _DECAF_UTIL_COMPARATORS_EQUALS_H_ */

http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/8c0f341a/activemq-cpp/src/main/decaf/util/comparators/Less.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/comparators/Less.h b/activemq-cpp/src/main/decaf/util/comparators/Less.h
index 1e4ec5f..5a10cbf 100644
--- a/activemq-cpp/src/main/decaf/util/comparators/Less.h
+++ b/activemq-cpp/src/main/decaf/util/comparators/Less.h
@@ -29,7 +29,9 @@ namespace comparators {
      * less than the second.  This can be used in Collection classes to sort elements
      * according to their natural ordering.  By design the Comparator's compare function
      * return more information about comparison than the STL binary function's boolean
-     * compare operator.  In this case the compare method will return
+     * compare operator.  In this case the compare method will return a value of zero if
+     * two values are equal or a positive or negative value to indicate greater than or
+     * less then.
      *
      * @since 1.0
      */
@@ -40,15 +42,15 @@ namespace comparators {
         Less() {}
         virtual ~Less() {}
 
-        virtual bool operator() ( const E& left, const E& right ) const {
+        virtual bool operator()(const E& left, const E& right) const {
             return left < right;
         }
 
-        virtual int compare( const E& o1, const E& o2 ) const {
+        virtual int compare(const E& o1, const E& o2) const {
 
-            if( o1 > o2 ) {
+            if (o1 > o2) {
                 return 1;
-            } else if( o1 < o2 ) {
+            } else if (o1 < o2) {
                 return -1;
             }
 


Mime
View raw message