summaryrefslogtreecommitdiff
path: root/src/common.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.hpp')
-rw-r--r--src/common.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/common.hpp b/src/common.hpp
index c39f8c07..4c8d5f23 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -15,6 +15,59 @@
#include "include/rustic.hpp" // slice and option
#include "include/compile_error.hpp"
+enum Ordering
+{
+ OrdLess,
+ OrdEqual,
+ OrdGreater,
+};
+template<typename T>
+Ordering ord(const ::std::vector<T>& l, const ::std::vector<T>& r)
+{
+ unsigned int i = 0;
+ for(const auto& it : l)
+ {
+ if( i > r.size() )
+ return OrdGreater;
+
+ auto rv = it.ord(r[i]);
+ if( rv != OrdEqual )
+ return rv;
+
+ i ++;
+ }
+
+ return OrdEqual;
+}
+static inline Ordering ord(bool l, bool r)
+{
+ if(l == r)
+ return OrdEqual;
+ else if( l )
+ return OrdGreater;
+ else
+ return OrdLess;
+}
+static inline Ordering ord(unsigned l, unsigned r)
+{
+ if(l == r)
+ return OrdEqual;
+ else if( l > r )
+ return OrdGreater;
+ else
+ return OrdLess;
+}
+static inline Ordering ord(const ::std::string& l, const ::std::string& r)
+{
+ if(l == r)
+ return OrdEqual;
+ else if( l > r )
+ return OrdGreater;
+ else
+ return OrdLess;
+}
+
+
template <typename T>
struct LList
{