scala.math

trait Ordering

[source: scala/math/Ordering.scala]

@serializable

trait Ordering[T]
extends java.util.Comparator[T] with PartialOrdering[T]
A trait for representing total orderings. It is important to distinguish between a type that has a total order and a representation of total ordering on some type. This trait is for representing the latter. A total ordering is a binary relation on a type T that is also an equivalence relation and partial ordering on values of type T. This relation is exposed as the compare method of the Ordering trait. This relation must be:
Author
Geoffrey Washburn
Version
0.9.5, 2008-04-15
Since
2.7
Direct Known Subclasses:
Numeric, Ordering.UnitOrdering, Ordering.BooleanOrdering, Ordering.ByteOrdering, Ordering.CharOrdering, Ordering.ShortOrdering, Ordering.IntOrdering, Ordering.LongOrdering, Ordering.FloatOrdering, Ordering.DoubleOrdering, Ordering.BigIntOrdering, Ordering.BigDecimalOrdering, Ordering.StringOrdering

Method Summary
abstract def compare (x : T, y : T) : Int
Returns a negative integer iff x comes before y in the ordering, returns 0 iff x is the same in the ordering as y, and returns a positive number iff x comes after y in the ordering.
override def equiv (x : T, y : T) : Boolean
Returns true iff x is equivalent to y in the ordering.
override def gt (x : T, y : T) : Boolean
Returns true iff y comes before x in the ordering and is not the same as x.
override def gteq (x : T, y : T) : Boolean
Returns true iff y comes before x in the ordering.
override def lt (x : T, y : T) : Boolean
Returns true iff x comes before y in the ordering and is not the same as y.
override def lteq (x : T, y : T) : Boolean
Returns true iff x comes before y in the ordering.
def max (x : T, y : T) : T
Returns the argument which comes later in the ordering.
def min (x : T, y : T) : T
Returns the argument which comes earlier in the ordering.
implicit def mkOrderingOps (lhs : T) : Ops
def on [U](f : (U) => T) : Ordering[U]
Given a function U => T, creates Ordering[U].
override def reverse : Ordering[T]
def tryCompare (x : T, y : T) : Some[Int]
An Ordering is defined at all x and y.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
class Ops (lhs : T) extends AnyRef
Method Details
def tryCompare(x : T, y : T) : Some[Int]
An Ordering is defined at all x and y.
Overrides
PartialOrdering.tryCompare

abstract def compare(x : T, y : T) : Int
Returns a negative integer iff x comes before y in the ordering, returns 0 iff x is the same in the ordering as y, and returns a positive number iff x comes after y in the ordering.
Overrides
java.util.Comparator.java.util.Comparator.compare

override def lteq(x : T, y : T) : Boolean
Returns true iff x comes before y in the ordering.
Overrides
PartialOrdering.lteq

override def gteq(x : T, y : T) : Boolean
Returns true iff y comes before x in the ordering.
Overrides
PartialOrdering.gteq

override def lt(x : T, y : T) : Boolean
Returns true iff x comes before y in the ordering and is not the same as y.
Overrides
PartialOrdering.lt

override def gt(x : T, y : T) : Boolean
Returns true iff y comes before x in the ordering and is not the same as x.
Overrides
PartialOrdering.gt

override def equiv(x : T, y : T) : Boolean
Returns true iff x is equivalent to y in the ordering.
Overrides
PartialOrdering.equiv

def max(x : T, y : T) : T
Returns the argument which comes later in the ordering.

def min(x : T, y : T) : T
Returns the argument which comes earlier in the ordering.

override def reverse : Ordering[T]
Overrides
PartialOrdering.reverse

def on[U](f : (U) => T) : Ordering[U]
Given a function U => T, creates Ordering[U].

implicit def mkOrderingOps(lhs : T) : Ops