This inner class defines comparison operators available forT.
This inner class defines comparison operators available forT.
It can't extendAnyVal because it is not a top-level class or a member of a statically accessible object.
[Since version 2.13.0]use `sign` method insteadReturn true ifx ==y in the ordering.
Return true ifx ==y in the ordering.
Return true ifx >y in the ordering.
Return true ifx >y in the ordering.
Return true ifx >=y in the ordering.
Return true ifx >=y in the ordering.
Returns whether or not the other ordering is the opposite ordering of this one.
Returns whether or not the other ordering is the opposite ordering of this one.
Equivalent toother == this.reverse.
Implementations should only override this method if they are overridingreverse as well.
Return true ifx <y in the ordering.
Return true ifx <y in the ordering.
Return true ifx <=y in the ordering.
Return true ifx <=y in the ordering.
Returnx ifx >=y, otherwisey.
Returnx ifx <=y, otherwisey.
Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:
Given f, a function from U into T, creates an Ordering[U] whose compare function is equivalent to:
def compare(x:U, y:U) = Ordering[T].compare(f(x), f(y))Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result ofothers compare function.
Creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else the result ofothers compare function.
an Ordering to use if this Ordering returns zero
case class Pair(a: Int, b: Int)val pairOrdering = Ordering.by[Pair, Int](_.a) .orElse(Ordering.by[Pair, Int](_.b))Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:
Given f, a function from T into S, creates an Ordering[T] whose compare function returns the result of this Ordering's compare function, if it is non-zero, or else a result equivalent to:
Ordering[S].compare(f(x), f(y))This function is equivalent to passing the result ofOrdering.by(f) toorElse.
case class Pair(a: Int, b: Int)val pairOrdering = Ordering.by[Pair, Int](_.a) .orElseBy[Int](_.b)Return the opposite ordering of this one.
Return the opposite ordering of this one.
Implementations overriding this method MUST overrideisReverseOf as well if they change the behavior at all (for example, caching does not require overriding it).
Returns whether a comparison betweenx andy is defined, and if so the result ofcompare(x, y).
Returns whether a comparison betweenx andy is defined, and if so the result ofcompare(x, y).
Returns an integer whose sign communicates how x compares to y.
Returns an integer whose sign communicates how x compares to y.
The result sign has the following meaning:
- negative if x < y - positive if x > y - zero otherwise (if x == y)
This implicit method augmentsT with the comparison operators defined inscala.math.Ordering.Ops.
This implicit method augmentsT with the comparison operators defined inscala.math.Ordering.Ops.