diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-02 13:21:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-02 13:21:17 +0000 |
commit | 2bb5db8e23f54ecea3bc82c48d408ec61c3cd25b (patch) | |
tree | 99ccc3aa4c0edacfb907df35e61b0b47f3c331cf /src/dotnet-library/scalax/collection/immutable/List.scala | |
parent | 4603e36f932a18eb17a41aecc6b9e74c7655ff0f (diff) | |
download | scala-2bb5db8e23f54ecea3bc82c48d408ec61c3cd25b.tar.gz scala-2bb5db8e23f54ecea3bc82c48d408ec61c3cd25b.tar.bz2 scala-2bb5db8e23f54ecea3bc82c48d408ec61c3cd25b.zip |
Synced src/dotnet-library with rev 17621 of src...
Synced src/dotnet-library with rev 17621 of src/library
Diffstat (limited to 'src/dotnet-library/scalax/collection/immutable/List.scala')
-rw-r--r-- | src/dotnet-library/scalax/collection/immutable/List.scala | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/dotnet-library/scalax/collection/immutable/List.scala b/src/dotnet-library/scalax/collection/immutable/List.scala index c30f3b772f..72af5a0278 100644 --- a/src/dotnet-library/scalax/collection/immutable/List.scala +++ b/src/dotnet-library/scalax/collection/immutable/List.scala @@ -12,7 +12,8 @@ package scalax.collection.immutable import mutable.ListBuffer -import generic.covariant.{SequenceTemplate, SequenceFactory} +import generic.{SequenceTemplate, SequenceFactory, EmptyIterableFactory, Builder} +import annotation.unchecked.uncheckedVariance /** A class representing an ordered collection of elements of type * <code>a</code>. This class comes with two implementing case @@ -23,7 +24,9 @@ import generic.covariant.{SequenceTemplate, SequenceFactory} * @author Martin Odersky and others * @version 2.8 */ -sealed abstract class List[+A] extends Stream[A] with SequenceTemplate[List, A] with Product { +sealed abstract class List[+A] extends Stream[A] + with SequenceTemplate[List, A @uncheckedVariance] + with Product { import collection.{Iterable, OrderedIterable, Sequence, Vector} @@ -549,7 +552,7 @@ final case class ::[B](private var hd: B, private[scalax] var tl: List[B]) exten * @author Martin Odersky and others * @version 1.0, 15/07/2003 */ -object List extends SequenceFactory[List] { +object List extends SequenceFactory[List] with EmptyIterableFactory[List] { override val empty: List[Nothing] = Nil @@ -566,7 +569,9 @@ object List extends SequenceFactory[List] { * @deprecated use @see iterate instead. * @param start the start value of the list * @param end the end value of the list - * @param step the increment function of the list, must be monotonically increasing or decreasing + * @param step the increment function of the list, which given <code>v<sub>n</sub></code>, + * computes <code>v<sub>n+1</sub></code>. Must be monotonically increasing + * or decreasing. * @return the sorted list of all integers in range [start;end). */ @deprecated def range(start: Int, end: Int, step: Int => Int): List[Int] = { @@ -576,7 +581,10 @@ object List extends SequenceFactory[List] { var i = start while ((!up || i < end) && (!down || i > end)) { b += i - i += step(i) + val next = step(i) + if (i == next) + throw new IllegalArgumentException("the step function did not make any progress on "+ i) + i = next } b.toList } @@ -693,7 +701,7 @@ object List extends SequenceFactory[List] { * in the same order * @deprecated use `array.toList` instead */ - def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length) + @deprecated def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length) /** Converts a range of an array into a list. * |