List journeys in descending order of time
[harbour-pedalo.git] / src / journey.h
index 560937e..cd3df88 100644 (file)
@@ -8,6 +8,9 @@
 class Journey
 {
 public:
+    friend class JourneyTimeDescending;
+    friend class JourneyTimeAscending;
+
     Journey();
     Journey(quint64 start, quint32 duration, quint32 overtook, quint32 overtakenby);
 
@@ -34,4 +37,18 @@ private:
     quint32 overtakenby;
 };
 
+class JourneyTimeAscending : std::binary_function<Journey,Journey, bool> {
+public:
+    bool operator() (Journey const &lhs, Journey const &rhs) const {
+        return lhs.start < rhs.start;
+    }
+};
+
+class JourneyTimeDescending : std::binary_function<Journey,Journey, bool> {
+public:
+    bool operator() (Journey const &lhs, Journey const &rhs) const {
+        return lhs.start > rhs.start;
+    }
+};
+
 #endif // JOURNEY_H