From c0ff2852684b2804d4805dcf27590bddbf30cf59 Mon Sep 17 00:00:00 2001 From: Claus Stadler Date: Mon, 23 Sep 2024 18:07:05 +0200 Subject: [PATCH] Added comparator to AllenRelations. --- .../org/aksw/commons/algebra/allen/AllenRelations.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aksw-commons-algebra-parent/aksw-commons-algebra-allen-interval/src/main/java/org/aksw/commons/algebra/allen/AllenRelations.java b/aksw-commons-algebra-parent/aksw-commons-algebra-allen-interval/src/main/java/org/aksw/commons/algebra/allen/AllenRelations.java index 86b51933..2a7de55d 100644 --- a/aksw-commons-algebra-parent/aksw-commons-algebra-allen-interval/src/main/java/org/aksw/commons/algebra/allen/AllenRelations.java +++ b/aksw-commons-algebra-parent/aksw-commons-algebra-allen-interval/src/main/java/org/aksw/commons/algebra/allen/AllenRelations.java @@ -28,6 +28,16 @@ public static > AllenRelation compute(Range x, Range< return AllenRelation.of(pattern); } + /** A comparator that returns 0 when the argument ranges overlap, -1 if the first argument is before the other one, and 1 otherwise. */ + public static > int compare(Range x, Range y) { + int result = isBefore(x, y) + ? -1 + : isAfter(x, y) + ? 1 + : 0; + return result; + } + /** is strictly before (not meeting) */ public static > boolean isBefore(Range x, Range y) { boolean result =