Skip to content

Commit

Permalink
Added comparator to AllenRelations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aklakan committed Sep 23, 2024
1 parent 12b5dba commit c0ff285
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public static <T extends Comparable<T>> AllenRelation compute(Range<T> 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 <T extends Comparable<T>> int compare(Range<T> x, Range<T> y) {
int result = isBefore(x, y)
? -1
: isAfter(x, y)
? 1
: 0;
return result;
}

/** is strictly before (not meeting) */
public static <T extends Comparable<T>> boolean isBefore(Range<T> x, Range<T> y) {
boolean result =
Expand Down

0 comments on commit c0ff285

Please sign in to comment.