trait PartialOrder[A] extends Eq[A]
The PartialOrder type class is used to define a partial ordering on some type A.
A partial order is defined by a relation <=, which obeys the following laws:
- x <= x (reflexivity) - if x <= y and y <= x, then x === y (anti-symmetry) - if x <= y and y <= z, then x <= z (transitivity)
To compute both <= and >= at the same time, we use a Double number to encode the result of the comparisons x <= y and x >= y. The truth table is defined as follows:
x <= y x >= y Double true true = 0.0 (corresponds to x === y) false false = NaN (x and y cannot be compared) true false = -1.0 (corresponds to x < y) false true = 1.0 (corresponds to x > y)
- Self Type
- PartialOrder[A]
- Alphabetic
- By Inheritance
- PartialOrder
- Eq
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
getClass(): Class[_]
- Definition Classes
- Any
-
abstract
def
partialCompare(x: A, y: A): Double
Result of comparing
xwithy.Result of comparing
xwithy. Returns NaN if operands are not comparable. If operands are comparable, returns a Double whose sign is: - negative iffx < y- zero iffx === y- positive iffx > y
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
equals(arg0: Any): Boolean
- Definition Classes
- Any
-
def
eqv(x: A, y: A): Boolean
Returns
trueifxandyare equivalent,falseotherwise.Returns
trueifxandyare equivalent,falseotherwise.- Definition Classes
- PartialOrder → Eq
- def gt(x: A, y: A): Boolean
- def gteqv(x: A, y: A): Boolean
-
def
hashCode(): Int
- Definition Classes
- Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lt(x: A, y: A): Boolean
- def lteqv(x: A, y: A): Boolean
-
def
neqv(x: A, y: A): Boolean
Returns
falseifxandyare equivalent,trueotherwise.Returns
falseifxandyare equivalent,trueotherwise.- Definition Classes
- Eq
-
def
on[B](f: (B) ⇒ A): PartialOrder[B]
Defines a partial order on
Bby mappingBtoAusingfand usingAs order to orderB.Defines a partial order on
Bby mappingBtoAusingfand usingAs order to orderB.- Definition Classes
- PartialOrder → Eq
-
def
pmax(x: A, y: A): Option[A]
Returns Some(x) if x >= y, Some(y) if x < y, otherwise None.
-
def
pmin(x: A, y: A): Option[A]
Returns Some(x) if x <= y, Some(y) if x > y, otherwise None.
-
def
reverse: PartialOrder[A]
Defines a partial order on
Awhere all arrows switch direction. -
def
toString(): String
- Definition Classes
- Any
-
def
tryCompare(x: A, y: A): Option[Int]
Result of comparing
xwithy.Result of comparing
xwithy. Returns None if operands are not comparable. If operands are comparable, returns Some[Int] where the Int sign is: - negative iffx < y- zero iffx == y- positive iffx > y