blob: b0ddf70220742e895107b5fc8a2a9b150a27889e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala
/** A class for partially ordered data.
*
* @author Martin Odersky
* @version 1.0, 23/04/2004
*/
trait PartiallyOrdered[+A] {
/** Result of comparing <code>this</code> with operand <code>that</code>.
* Returns <code>None</code> if operands are not comparable.
* If operands are comparable, returns <code>Some(x)</code> where
* <code>x < 0</code> iff <code>this < that</code>
* <code>x == 0</code> iff <code>this == that</code>
* <code>x > 0</code> iff <code>this > that</code>
*/
def tryCompareTo [B >: A <% PartiallyOrdered[B]](that: B): Option[Int]
def < [B >: A <% PartiallyOrdered[B]](that: B): Boolean =
(this tryCompareTo that) match {
case Some(x) if x < 0 => true
case _ => false
}
def > [B >: A <% PartiallyOrdered[B]](that: B): Boolean =
(this tryCompareTo that) match {
case Some(x) if x > 0 => true
case _ => false
}
def <= [B >: A <% PartiallyOrdered[B]](that: B): Boolean =
(this tryCompareTo that) match {
case Some(x) if x <= 0 => true
case _ => false
}
def >= [B >: A <% PartiallyOrdered[B]](that: B): Boolean =
(this tryCompareTo that) match {
case Some(x) if x >= 0 => true
case _ => false
}
}
|