summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-19 12:38:06 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-19 12:38:06 +0000
commitfcbf3715187470c8568057bebb7f9577f6163e88 (patch)
treea971e1c7fdf41c6f867be36157d658c3f686576f /src/library
parent1ab5e1578c600e7fe415998fa3f13afed7d7fb14 (diff)
downloadscala-fcbf3715187470c8568057bebb7f9577f6163e88.tar.gz
scala-fcbf3715187470c8568057bebb7f9577f6163e88.tar.bz2
scala-fcbf3715187470c8568057bebb7f9577f6163e88.zip
Fixes #3935.
No review.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala2
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala11
-rw-r--r--src/library/scala/collection/mutable/Queue.scala12
3 files changed, 21 insertions, 4 deletions
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 28d2f637db..53c99216c2 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -192,7 +192,7 @@ class ListMap[A, +B] extends Map[A, B] with MapLike[A, B, ListMap[A, B]] {
// if (tail eq next) this
// else new tail.Node(key, value)
// }
- // we use an imperative one instead:
+ // we use an imperative one instead (and use an auxiliary list to preserve order!):
var cur: ListMap[A, B1] = this
var lst: List[(A, B1)] = Nil
while (cur.nonEmpty) {
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index 65c973c9ec..a81cb27cf1 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -42,7 +42,7 @@ class MutableList[A] extends LinearSeq[A]
/** Returns the first element in this list
*/
- override def head: A = first0.head
+ override def head: A = if (nonEmpty) first0.head else throw new NoSuchElementException
/** Returns the rest of this list
*/
@@ -134,3 +134,12 @@ class MutableList[A] extends LinearSeq[A]
def result = this
}
+
+
+object MutableList {
+
+}
+
+
+
+
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index ae6c60d1d0..9fb34b07aa 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -30,6 +30,14 @@ import generic._
*/
@serializable @cloneable
class Queue[A] extends MutableList[A] with Cloneable[Queue[A]] {
+
+ protected def this(fst: LinkedList[A], lst: LinkedList[A], lng: Int) {
+ this()
+ first0 = fst
+ last0 = lst
+ len = lng
+ }
+
/** Adds all elements to the queue.
*
* @param elems the elements to add.
@@ -147,10 +155,10 @@ class Queue[A] extends MutableList[A] with Cloneable[Queue[A]] {
*
* @return the first element.
*/
- def front: A = first0.elem
+ def front: A = head
}
-// !!! TODO - integrate
+
object Queue {
def apply[A](xs: A*): Queue[A] = new Queue[A] ++= xs
}