summaryrefslogtreecommitdiff
path: root/sources/scala/Ordered.scala
blob: 2a75d68923a604c042121fbba6043f6685503808 (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
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-04, LAMP/EPFL               **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
** $Id$
\*                                                                      */

package scala;


/** A trait for totally ordered data.
 */
trait Ordered[+a] {

  /** Result of comparing `this' with operand `that'.
   *  returns `x' where
   *  <code>x &lt; 0</code>    iff    <code>this &lt; that</code>
   *  <code>x == 0</code>   iff    <code>this == that</code>
   *  <code>x &gt; 0</code>    iff    <code>this &gt; that</code>
   */
  def compareTo [b >: a <% Ordered[b]](that: b): int;

  def <  [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <  0;

  def >  [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >  0;

  def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0;

  def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0;
}