Is there a good way to implement an ordered pair? ...
# announcements
s
Is there a good way to implement an ordered pair? Say, I want a
data class OrderedPair(val low: Int, val high: Int)
with
low
always <=
high
. So
OrderedPair(2, 5)
and
OrderedPair(5, 2)
would result in equivalent objects with
low=2
and
high=5
. I'd like this to be a
data class
so I do not have to override `equals()`/`hashCode()` and Co. by hand.