partiallyordered.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 51 行
SCALA
51 行
/* __ *\** ________ ___ / / ___ Scala API **** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: PartiallyOrdered.scala 11950 2007-06-08 12:08:26Z michelou $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 }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?