A trait for linearly ordered additive commutative monoid. The following laws holds:
(1) if `a <= b` then `a + c <= b + c` (linear order),
(2) `signum(x) = -1` if `x < 0`, `signum(x) = 1` if `x > 0`, `signum(x) = 0` otherwise,
Negative elements only appear when scalar
is a additive abelian group, and then
(3) `abs(x) = -x` if `x < 0`, or `x` otherwise,
Laws (1) and (2) lead to the triange inequality:
(4) `abs(a + b) <= abs(a) + abs(b)`
Signed should never be extended in implementations, rather the AdditiveCMonoid and AdditiveAbGroup subtraits. We
cannot use self-types to express the constraint self: AdditiveCMonoid =>
(interaction with specialization?).
- Companion
- object
Value members
Abstract methods
An idempotent function that ensures an object has a non-negative sign.
An idempotent function that ensures an object has a non-negative sign.
Concrete methods
Inherited methods
Result of comparing x
with y
. Returns an Int whose sign is:
Result of comparing x
with y
. Returns an Int whose sign is:
- negative iff
x < y
- zero iff
x = y
- positive iff
x > y
- Inherited from
- Order
Like compare
, but returns a cats.kernel.Comparison instead of an Int.
Has the benefit of being able to pattern match on, but not as performant.
Like compare
, but returns a cats.kernel.Comparison instead of an Int.
Has the benefit of being able to pattern match on, but not as performant.
- Inherited from
- Order
Returns true if x
= y
, false otherwise.
Returns true if x
= y
, false otherwise.
- Definition Classes
- Order -> PartialOrder -> Eq
- Inherited from
- Order
Returns true if x
> y
, false otherwise.
Returns true if x
> y
, false otherwise.
- Definition Classes
- Order -> PartialOrder
- Inherited from
- Order
Returns true if x
>= y
, false otherwise.
Returns true if x
>= y
, false otherwise.
- Definition Classes
- Order -> PartialOrder
- Inherited from
- Order
Returns true if x
< y
, false otherwise.
Returns true if x
< y
, false otherwise.
- Definition Classes
- Order -> PartialOrder
- Inherited from
- Order
Returns true if x
<= y
, false otherwise.
Returns true if x
<= y
, false otherwise.
- Definition Classes
- Order -> PartialOrder
- Inherited from
- Order
Returns true if x
!= y
, false otherwise.
Returns true if x
!= y
, false otherwise.
Note: this default implementation provided by Order is the same as the one defined in Eq, but for purposes of binary compatibility, the override in Order has not yet been removed. See this discussion.
- Definition Classes
- Order -> Eq
- Inherited from
- Order
Like partialCompare
, but returns a cats.kernel.Comparison instead of an Double.
Has the benefit of being able to pattern match on, but not as performant.
Like partialCompare
, but returns a cats.kernel.Comparison instead of an Double.
Has the benefit of being able to pattern match on, but not as performant.
- Inherited from
- PartialOrder
Returns Some(x) if x >= y, Some(y) if x < y, otherwise None.
Returns Some(x) if x >= y, Some(y) if x < y, otherwise None.
- Inherited from
- PartialOrder
Returns Some(x) if x <= y, Some(y) if x > y, otherwise None.
Returns Some(x) if x <= y, Some(y) if x > y, otherwise None.
- Inherited from
- PartialOrder
Convert a Order[A]
to a scala.math.Ordering[A]
instance.
Convert a Order[A]
to a scala.math.Ordering[A]
instance.
- Inherited from
- Order
Result of comparing x
with y
. Returns None if operands are
not comparable. If operands are comparable, returns Some[Int]
where the Int sign is:
Result of comparing x
with y
. Returns None if operands are
not comparable. If operands are comparable, returns Some[Int]
where the Int sign is:
- negative iff
x < y
- zero iff
x = y
- positive iff
x > y
- Inherited from
- PartialOrder