Scala Library
|
|
scala/math/Ordering.scala
]
trait
Ordering[T]
extends
java.util.Comparator[T] with
PartialOrdering[T]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:
compare(x, x) == 0
, for any x
of
type T
.compare(x, y) == z
and compare(y, x) == w
then math.signum(z) == -math.signum(w)
, for any x
and y
of
type T
and z
and w
of type Int
.compare(x, y) == z
and compare(y, w) == v
and math.signum(z) >= 0
and math.signum(v) >= 0
then
compare(x, w) == u
and math.signum(z + v) == math.signum(u)
,
for any x
, y
,
and w
of type T
and z
, v
, and u
of type Int
.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 |
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.true
iff x
comes before
y
in the ordering.true
iff y
comes before
x
in the ordering.true
iff x
comes before
y
in the ordering and is not the same as y
.true
iff y
comes before
x
in the ordering and is not the same as x
.true
iff x
is equivalent to
y
in the ordering.
Scala Library
|
|