Trait/Object

spire.algebra

PartialOrder

Related Docs: object PartialOrder | package algebra

Permalink

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]
Linear Supertypes
Eq[A], Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. PartialOrder
  2. Eq
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def getClass(): Class[_]

    Permalink
    Definition Classes
    Any
  2. abstract def partialCompare(x: A, y: A): Double

    Permalink

    Result of comparing x with y.

    Result of comparing x with y. 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

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  6. def eqv(x: A, y: A): Boolean

    Permalink

    Returns true if x and y are equivalent, false otherwise.

    Returns true if x and y are equivalent, false otherwise.

    Definition Classes
    PartialOrderEq
  7. def gt(x: A, y: A): Boolean

    Permalink
  8. def gteqv(x: A, y: A): Boolean

    Permalink
  9. def hashCode(): Int

    Permalink
    Definition Classes
    Any
  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. def lt(x: A, y: A): Boolean

    Permalink
  12. def lteqv(x: A, y: A): Boolean

    Permalink
  13. def neqv(x: A, y: A): Boolean

    Permalink

    Returns false if x and y are equivalent, true otherwise.

    Returns false if x and y are equivalent, true otherwise.

    Definition Classes
    Eq
  14. def on[B](f: (B) ⇒ A): PartialOrder[B]

    Permalink

    Defines a partial order on B by mapping B to A using f and using As order to order B.

    Defines a partial order on B by mapping B to A using f and using As order to order B.

    Definition Classes
    PartialOrderEq
  15. def pmax(x: A, y: A): Option[A]

    Permalink

    Returns Some(x) if x >= y, Some(y) if x < y, otherwise None.

  16. def pmin(x: A, y: A): Option[A]

    Permalink

    Returns Some(x) if x <= y, Some(y) if x > y, otherwise None.

  17. def reverse: PartialOrder[A]

    Permalink

    Defines a partial order on A where all arrows switch direction.

  18. def toString(): String

    Permalink
    Definition Classes
    Any
  19. def tryCompare(x: A, y: A): Option[Int]

    Permalink

    Result of comparing x with y.

    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 Eq[A]

Inherited from Any

Ungrouped