Provide a crude comparison operator< to permit CkArrayIndex in comparison-based conta...
authorRamprasad Venkataraman <ramv@illinois.edu>
Tue, 16 Apr 2013 21:05:41 +0000 (16:05 -0500)
committerRamprasad Venkataraman <ramv@illinois.edu>
Tue, 16 Apr 2013 22:28:40 +0000 (17:28 -0500)
src/ck-core/ckarrayindex.h

index f6f8176d404bf4d7605a66ce040bd559b4d6d34b..70f4e74be97c6fc924a15cecf00150a72f427727 100644 (file)
@@ -177,6 +177,18 @@ class CkArrayIndex: public CkArrayIndexBase
             for (int i=6; i < 2 * CK_ARRAYINDEX_MAXLEN; i++)
                 indexShorts[i] = 0;
         }
+
+
+        /// A very crude comparison operator to enable using in comparison-based containers
+        friend bool operator< (const CkArrayIndex &lhs, const CkArrayIndex &rhs)
+        {
+            if (lhs.nInts != rhs.nInts)
+                CkAbort("cannot compare two indices of different cardinality");
+            for (int i = 0; i < lhs.nInts; i++)
+                if (lhs.data()[i] >= rhs.data()[i])
+                    return false;
+            return true;
+        }
 };