--- a/include/orderlist.h Mon Dec 25 12:28:13 2006 -0500
+++ b/include/orderlist.h Fri Dec 29 18:20:50 2006 -0500
@@ -105,6 +105,7 @@
public:
typedef typename OrderList<T>::const_iterator ComparableType;
int compare(ComparableType a, ComparableType b) const; /// (-1,0,1) = a (precedes, ==, succeeds) b
+ bool operator()(ComparableType a, ComparableType b) const;
};
/// Structure storing auxilliary information requred for each node of OrderList
--- a/include/orderlist.hpp Mon Dec 25 12:28:13 2006 -0500
+++ b/include/orderlist.hpp Fri Dec 29 18:20:50 2006 -0500
@@ -108,3 +108,11 @@
if (a.get_base()->tag < b.get_base()->tag) return -1;
return 1;
}
+
+template<class T>
+bool
+OrderList<T>::OrderComparison::
+operator()(ComparableType a, ComparableType b) const
+{
+ return (compare(a,b) < 0);
+}
--- a/tests/test-orderlist.cpp Mon Dec 25 12:28:13 2006 -0500
+++ b/tests/test-orderlist.cpp Fri Dec 29 18:20:50 2006 -0500
@@ -1,7 +1,7 @@
#include "orderlist.h"
#include <iostream>
-typedef OrderList<int> OList;
+typedef OrderList<int> OList;
typedef OList::OrderComparison Comparison;
typedef OList::iterator iterator;
@@ -42,4 +42,8 @@
std::cout << "60 < 40: " << cmp.compare(i60,i40) << std::endl;
std::cout << "50 < 70: " << cmp.compare(i50,i70) << std::endl;
std::cout << "60 < 70: " << cmp.compare(i60,i70) << std::endl;
+ std::cout << std::endl;
+
+ std::cout << "60 < 40: " << cmp(i60, i40) << std::endl;
+ std::cout << "60 < 70: " << cmp(i60, i70) << std::endl;
}