summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/HashMap.scala
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-12-09 10:08:20 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-12-09 10:08:20 +0000
commitf2ecbd04691b1914e2f77c60afc2b296aa6826ae (patch)
tree539b543eb173cfc7b0bbde4ca5f2c5bb187297df /src/library/scala/collection/immutable/HashMap.scala
parent492b22576f2ad46b300ce8dc31c5b672aaf517e4 (diff)
downloadscala-f2ecbd04691b1914e2f77c60afc2b296aa6826ae.tar.gz
scala-f2ecbd04691b1914e2f77c60afc2b296aa6826ae.tar.bz2
scala-f2ecbd04691b1914e2f77c60afc2b296aa6826ae.zip
Array combiners implementation changed from arr...
Array combiners implementation changed from array buffers to doubling unrolled buffers to avoid excessive copying. Still evaluating the benefits of this. No review.
Diffstat (limited to 'src/library/scala/collection/immutable/HashMap.scala')
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 4a7a10c6c1..f6e17e9630 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -473,14 +473,25 @@ time { mNew.iterator.foreach( p => ()) }
}
class TrieIterator[A, +B](elems: Array[HashMap[A, B]]) extends Iterator[(A, B)] {
- private[this] var depth = 0
- private[this] var arrayStack = new Array[Array[HashMap[A,B]]](6)
- private[this] var posStack = new Array[Int](6)
-
- private[this] var arrayD = elems
- private[this] var posD = 0
-
- private[this] var subIter: Iterator[(A, B)] = null // to traverse collision nodes
+ protected var depth = 0
+ protected var arrayStack: Array[Array[HashMap[A, B @uncheckedVariance]]] = new Array[Array[HashMap[A,B]]](6)
+ protected var posStack = new Array[Int](6)
+
+ protected var arrayD: Array[HashMap[A, B @uncheckedVariance]] = elems
+ protected var posD = 0
+
+ protected var subIter: Iterator[(A, B @uncheckedVariance)] = null // to traverse collision nodes
+
+ def dupIterator: TrieIterator[A, B] = {
+ val t = new TrieIterator(elems)
+ t.depth = depth
+ t.arrayStack = arrayStack
+ t.posStack = posStack
+ t.arrayD = arrayD
+ t.posD = posD
+ t.subIter = subIter
+ t
+ }
def hasNext = (subIter ne null) || depth >= 0