summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorstepancheg <stepancheg@epfl.ch>2008-05-29 13:10:23 +0000
committerstepancheg <stepancheg@epfl.ch>2008-05-29 13:10:23 +0000
commit8de595a5d4a6dd0238b2a2acf2f3bebef596c029 (patch)
tree96b57b16a646ba0cdcf740d4f237349f9e3a0a13 /src
parent859d2bbba89d435529f8d0213e3a9fa5d7adc493 (diff)
downloadscala-8de595a5d4a6dd0238b2a2acf2f3bebef596c029.tar.gz
scala-8de595a5d4a6dd0238b2a2acf2f3bebef596c029.tar.bz2
scala-8de595a5d4a6dd0238b2a2acf2f3bebef596c029.zip
fix documentation of lengthCompare method
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/List.scala11
-rw-r--r--src/library/scala/Seq.scala8
-rw-r--r--src/library/scala/Stream.scala14
3 files changed, 27 insertions, 6 deletions
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 0198813914..f6f10161d6 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -456,7 +456,16 @@ sealed abstract class List[+A] extends Seq[A] {
*/
def head: A
- /** returns length - l, without calling length
+ /** Result of comparing <code>length</code> with operand <code>l</code>.
+ * returns <code>x</code> where
+ * <code>x &lt; 0</code> iff <code>this.length &lt; l</code>
+ * <code>x == 0</code> iff <code>this.length == l</code>
+ * <code>x &gt; 0</code> iff <code>this.length &gt; that</code>.
+ *
+ * This method is used by matching streams against right-ignoring (...,_*) patterns.
+ *
+ * This method does not call <code>List.length</code>, it works for <code>O(l)</code>,
+ * not for <code>O(length)</code>.
*/
override def lengthCompare(l: Int) = {
if (isEmpty) 0 - l
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index c3720427e1..3b184a1ba5 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -140,7 +140,13 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
*/
def length: Int
- /** Returns length - l. This method is used by matching streams against right-ignoring (...,_*) patterns.
+ /** Result of comparing <code>length</code> with operand <code>l</code>.
+ * returns <code>x</code> where
+ * <code>x &lt; 0</code> iff <code>this.length &lt; l</code>
+ * <code>x == 0</code> iff <code>this.length == l</code>
+ * <code>x &gt; 0</code> iff <code>this.length &gt; that</code>.
+ *
+ * This method is used by matching streams against right-ignoring (...,_*) patterns.
* Lazy sequences should override this method if length forces evaluation of the stream.
*/
def lengthCompare(l: Int): Int = length - l
diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala
index 541ffd833d..6765ec1db8 100644
--- a/src/library/scala/Stream.scala
+++ b/src/library/scala/Stream.scala
@@ -243,10 +243,16 @@ abstract class Stream[+A] extends Seq.Projection[A] {
len
}
- /** Returns
- * - (length - l) if l >= length
- * - 1 otherwise
- * This method does not call Stream.length.
+ /** Result of comparing <code>length</code> with operand <code>l</code>.
+ * returns <code>x</code> where
+ * <code>x &lt; 0</code> iff <code>this.length &lt; l</code>
+ * <code>x == 0</code> iff <code>this.length == l</code>
+ * <code>x &gt; 0</code> iff <code>this.length &gt; that</code>.
+ *
+ * This method is used by matching streams against right-ignoring (...,_*) patterns.
+ *
+ * This method does not call <code>Stream.length</code>, it works for <code>O(l)</code>,
+ * not for <code>O(length)</code> and does not force full Stream evaluation.
*/
final override def lengthCompare(l: Int) = {
if (isEmpty) 0 - l