DoubleTotalOrderTrait

org.saddle.util.DoubleTotalOrderTrait
trait DoubleTotalOrderTrait extends Order[Double] with Hash[Double]

An Order[Double] instance which produces a total order by ordering NaNs above all other Doubles

Contrary to the specification of cats, the DoubleOrdering in cats.kernel is not total because NaN is not ordered (all comparisons return false). This behaviour is consistent with IEEE-754, but not very practical.

java.lang.Double.compare orders NaN to be largest of all Doubles.

See https://github.com/scala/scala/pull/8721 See https://github.com/scala/scala/blob/39e82c3f904380f0b40d106723747faf881640d4/src/library/scala/math/Ordering.scala#L465

Attributes

Graph
Supertypes
trait Hash[Double]
trait Order[Double]
trait PartialOrder[Double]
trait Eq[Double]
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
object doubleIsNumeric.type
object DoubleTotalOrder.type

Members list

Concise view

Value members

Concrete methods

def compare(x: Double, y: Double): Int

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

Attributes

override def eqv(x: Double, y: Double): Boolean

Returns true if x = y, false otherwise.

Returns true if x = y, false otherwise.

Attributes

Definition Classes
Order -> PartialOrder -> Eq
override def gt(x: Double, y: Double): Boolean

Returns true if x > y, false otherwise.

Returns true if x > y, false otherwise.

Attributes

Definition Classes
Order -> PartialOrder
override def gteqv(x: Double, y: Double): Boolean

Returns true if x >= y, false otherwise.

Returns true if x >= y, false otherwise.

Attributes

Definition Classes
Order -> PartialOrder
def hash(x: Double): Int

Returns the hash code of the given object under this hashing scheme.

Returns the hash code of the given object under this hashing scheme.

Attributes

override def lt(x: Double, y: Double): Boolean

Returns true if x < y, false otherwise.

Returns true if x < y, false otherwise.

Attributes

Definition Classes
Order -> PartialOrder
override def lteqv(x: Double, y: Double): Boolean

Returns true if x <= y, false otherwise.

Returns true if x <= y, false otherwise.

Attributes

Definition Classes
Order -> PartialOrder
override def max(x: Double, y: Double): Double

If x > y, return x, else return y.

If x > y, return x, else return y.

Attributes

Definition Classes
Order
override def min(x: Double, y: Double): Double

If x < y, return x, else return y.

If x < y, return x, else return y.

Attributes

Definition Classes
Order
override def neqv(x: Double, y: Double): Boolean

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.

Attributes

Definition Classes
Order -> Eq

Inherited methods

def comparison(x: Double, y: Double): Comparison

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.

Attributes

Inherited from:
Order
def partialCompare(x: Double, y: Double): Double

Result of comparing x with y. Returns NaN if operands are not comparable. If operands are comparable, returns a Double whose sign is:

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

Attributes

Inherited from:
Order
def partialComparison(x: Double, y: Double): Option[Comparison]

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.

Attributes

Inherited from:
PartialOrder
def pmax(x: Double, y: Double): 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.

Attributes

Inherited from:
PartialOrder
def pmin(x: Double, y: Double): 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.

Attributes

Inherited from:
PartialOrder
def toOrdering: Ordering[A]

Convert a Order[A] to a scala.math.Ordering[A] instance.

Convert a Order[A] to a scala.math.Ordering[A] instance.

Attributes

Inherited from:
Order
def tryCompare(x: Double, y: Double): Option[Int]

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

Attributes

Inherited from:
PartialOrder