1 package frost.core
2
3 ====================================================================================================
4 Interface for objects which can be compared for equality and ordering. To fully implement this
5 interface, only the `=` (inherited from `Equatable`) and `>` operators are required, as the others
6 all have default implementations.
7 ====================================================================================================
8 interface Comparable<T:Comparable<T>> : Equatable<T> {
9 function >(other:T):Bit
10
11 @default
12 function <(other:T):Bit {
13 return other > self->T
14 }
15
16 @default
17 function >=(other:T):Bit {
18 return !(self < other)
19 }
20
21 @default
22 function <=(other:T):Bit {
23 return !(self > other)
24 }
25 }