*
* @author Georgios Gousios <gousiosg@gmail.com>
*/
-case class Timeslot(from: Date, to: Date) {
+case class Timeslot(from: Date, to: Date) extends Ordered[Timeslot] {
/* Preconditions to ensure correct object creations */
assert(from != null)
start ++ build(List(), overlaps) ++ end
}
+
+ /**
+ * Compares the starting times of two timeslots.
+ */
+ def compare(that: Timeslot): Int = {
+ if (this.startsBefore(that)) -1
+ else if (this.startsAfter(that)) 1
+ else 0
+ }
}
\ No newline at end of file