diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2008-08-12 16:34:31 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2008-08-12 16:34:31 +0000 |
commit | 0d31778efe0e28e3c71294afc8a3cf7d149094c4 (patch) | |
tree | bb50d09c786d21f19704bbd11cdd4ee47267461f | |
parent | 28e36e9a74b0120f4f105e204571470036c986f7 (diff) | |
download | scala-0d31778efe0e28e3c71294afc8a3cf7d149094c4.tar.gz scala-0d31778efe0e28e3c71294afc8a3cf7d149094c4.tar.bz2 scala-0d31778efe0e28e3c71294afc8a3cf7d149094c4.zip |
Added David's fix for #1184 and author
-rw-r--r-- | src/library/scala/collection/immutable/TreeHashMap.scala | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/TreeHashMap.scala b/src/library/scala/collection/immutable/TreeHashMap.scala index 1e0dd490fa..27f5112e0c 100644 --- a/src/library/scala/collection/immutable/TreeHashMap.scala +++ b/src/library/scala/collection/immutable/TreeHashMap.scala @@ -1,6 +1,15 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2008, David MacIver ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ package scala.collection.immutable; -object TreeHashMap{ +object TreeHashMap { private[TreeHashMap] val _empty = new TreeHashMap[Any, Nothing](IntMap.empty[Nothing]); def empty[Key, Value] : TreeHashMap[Key, Value] = _empty.asInstanceOf[TreeHashMap[Key, Value]]; @@ -21,6 +30,8 @@ object TreeHashMap{ * * Performancewise, get and update seem to be somewhat slower than with a traditional hash map, but bulk operations * such as filter, foreach and transform appear to get something of a speedup. + * + * @author David MacIver */ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap[Key, Value]]) extends scala.collection.immutable.Map[Key, Value]{ def elements : Iterator[(Key, Value)] = new Iterator[(Key, Value)]{ @@ -104,6 +115,7 @@ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap case Some(table) => { val newtable = table - key; if (table eq newtable) this; + else if (newtable.isEmpty) TreeHashMap(underlying - h) else TreeHashMap(underlying.update(h, newtable)); } } |