activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r740458 - /activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h
Date Tue, 03 Feb 2009 21:26:27 GMT
Author: tabish
Date: Tue Feb  3 21:26:26 2009
New Revision: 740458

URL: http://svn.apache.org/viewvc?rev=740458&view=rev
Log:
Adds the ability to define what the comparison is for map keys, defaults to the standard std::less
comparitor.

Modified:
    activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h

Modified: activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h?rev=740458&r1=740457&r2=740458&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h (original)
+++ activemq/activemq-cpp/trunk/src/main/decaf/util/Map.h Tue Feb  3 21:26:26 2009
@@ -32,7 +32,8 @@
      * 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
{
+    template <typename K, typename V, typename COMPARE = std::less<K> > class
Map :
+        public concurrent::Synchronizable {
     private:
 
         std::map<K,V> valueMap;
@@ -94,7 +95,7 @@
          * @return true if this map contains the value, otherwise false.
          */
         virtual bool containsKey( const K& key ) const {
-            typename std::map<K,V>::const_iterator iter;
+            typename std::map<K,V,COMPARE>::const_iterator iter;
             iter = valueMap.find(key);
             return iter != valueMap.end();
         }
@@ -112,7 +113,7 @@
                 return false;
             }
 
-            typename std::map<K,V>::const_iterator iter = valueMap.begin();
+            typename std::map<K,V,COMPARE>::const_iterator iter = valueMap.begin();
             for( ; iter != valueMap.end(); ++iter ){
                 if( (*iter).second == value ) {
                     return true;
@@ -145,7 +146,7 @@
         virtual V getValue( const K& key ) const
             throw( lang::exceptions::NoSuchElementException ) {
 
-            typename std::map<K,V>::const_iterator iter;
+            typename std::map<K,V,COMPARE>::const_iterator iter;
             iter = valueMap.find(key);
             if( iter == valueMap.end() ){
                 throw lang::exceptions::NoSuchElementException( __FILE__,
@@ -180,7 +181,7 @@
         virtual std::vector<K> getKeys() const{
             std::vector<K> keys( valueMap.size() );
 
-            typename std::map<K,V>::const_iterator iter;
+            typename std::map<K,V,COMPARE>::const_iterator iter;
             iter=valueMap.begin();
             for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
                 keys[ix] = iter->first;
@@ -195,7 +196,7 @@
         virtual std::vector<V> getValues() const {
             std::vector<V> values( valueMap.size() );
 
-            typename std::map<K,V>::const_iterator iter;
+            typename std::map<K,V,COMPARE>::const_iterator iter;
             iter=valueMap.begin();
             for( int ix=0; iter != valueMap.end(); ++iter, ++ix ){
                 values[ix] = iter->second;



Mime
View raw message