InlinedOrdering

trait InlinedOrdering[T]

An inline equivalent of scala.Ordering. Each method call is fully inlined at the point of use.

An inline equivalent of scala.Ordering. Each method call is fully inlined at the point of use.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

inline def compare(inline x: T, inline y: T): Int

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)

Concrete methods

inline def compareAlias(inline x: T, inline y: T): Int
inline def equiv(inline x: T, inline y: T): Boolean

Return true if x == y in the ordering.

Return true if x == y in the ordering.

inline def gt(inline x: T, inline y: T): Boolean

Return true if x > y in the ordering.

Return true if x > y in the ordering.

inline def gteq(inline x: T, inline y: T): Boolean

Return true if x >= y in the ordering.

Return true if x >= y in the ordering.

inline def lt(inline x: T, inline y: T): Boolean

Return true if x < y in the ordering.

Return true if x < y in the ordering.

inline def lteq(inline x: T, inline y: T): Boolean

Return true if x <= y in the ordering.

Return true if x <= y in the ordering.

inline def max[U <: T](inline x: U, inline y: U): U

Return x if x >= y, otherwise y.

Return x if x >= y, otherwise y.

inline def min[U <: T](inline x: U, inline y: U): U

Return x if x <= y, otherwise y.

Return x if x <= y, otherwise y.

inline def on[U](inline f: U => T): Ordering[U]

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))
inline def orElse(inline other: Ordering[T]): Ordering[T]

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 of others 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 of others compare function.

Value Params
other

an Ordering to use if this Ordering returns zero

Example
case class Pair(a: Int, b: Int)
val pairOrdering = Ordering.by[Pair, Int](_.a)
                          .orElse(Ordering.by[Pair, Int](_.b))
inline def orElseBy[S](inline f: T => S)(inline ord: Ordering[S]): Ordering[T]

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 of Ordering.by(f) to orElse.

Example
case class Pair(a: Int, b: Int)
val pairOrdering = Ordering.by[Pair, Int](_.a)
                          .orElseBy[Int](_.b)
inline def tryCompare(inline x: T, inline y: T): Some[Int]

Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).

Returns whether a comparison between x and y is defined, and if so the result of compare(x, y).