trait Order[A] extends PartialOrder[A]
The Order
type class is used to define a total ordering on some type A
.
An order is defined by a relation <=, which obeys the following laws:
- either x <= y or y <= x (totality) - if x <= y and y <= x, then x == y (antisymmetry) - if x <= y and y <= z, then x <= z (transitivity)
The truth table for compare is defined as follows:
x <= y x >= y Int true true = 0 (corresponds to x == y) true false < 0 (corresponds to x < y) false true > 0 (corresponds to x > y)
By the totality law, x <= y and y <= x cannot be both false.
- Self Type
- Order[A]
- Source
- Order.scala
- Alphabetic
- By Inheritance
- Order
- PartialOrder
- Eq
- Serializable
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def comparison(x: A, y: A): Comparison
Like
compare
, but returns a cats.kernel.Comparison instead of an Int.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. - def equals(arg0: Any): Boolean
- Definition Classes
- Any
- def eqv(x: A, y: A): Boolean
Returns true if
x
=y
, false otherwise.Returns true if
x
=y
, false otherwise.- Definition Classes
- Order → PartialOrder → Eq
- def gt(x: A, y: A): Boolean
Returns true if
x
>y
, false otherwise.Returns true if
x
>y
, false otherwise.- Definition Classes
- Order → PartialOrder
- def gteqv(x: A, y: A): Boolean
Returns true if
x
>=y
, false otherwise.Returns true if
x
>=y
, false otherwise.- Definition Classes
- Order → PartialOrder
- def hashCode(): Int
- Definition Classes
- Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lt(x: A, y: A): Boolean
Returns true if
x
<y
, false otherwise.Returns true if
x
<y
, false otherwise.- Definition Classes
- Order → PartialOrder
- def lteqv(x: A, y: A): Boolean
Returns true if
x
<=y
, false otherwise.Returns true if
x
<=y
, false otherwise.- Definition Classes
- Order → PartialOrder
- def max(x: A, y: A): A
If x > y, return x, else return y.
- def min(x: A, y: A): A
If x < y, return x, else return y.
- def neqv(x: A, y: A): Boolean
Returns true if
x
!=y
, false otherwise. - def partialCompare(x: A, y: A): Double
Result of comparing
x
withy
.Result of comparing
x
withy
. Returns NaN if operands are not comparable. If operands are comparable, returns a Double whose sign is:- negative iff
x < y
- zero iff
x = y
- positive iff
x > y
- Definition Classes
- Order → PartialOrder
- negative iff
- def partialComparison(x: A, y: A): Option[Comparison]
Like
partialCompare
, but returns a cats.kernel.Comparison instead of an Double.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.- Definition Classes
- PartialOrder
- def pmax(x: A, y: A): Option[A]
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.
- Definition Classes
- PartialOrder
- def pmin(x: A, y: A): Option[A]
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.
- Definition Classes
- PartialOrder
- def toOrdering: Ordering[A]
Convert a
Order[A]
to ascala.math.Ordering[A]
instance. - def toString(): String
- Definition Classes
- Any
- def tryCompare(x: A, y: A): Option[Int]
Result of comparing
x
withy
.Result of comparing
x
withy
. 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
- Definition Classes
- PartialOrder
- negative iff