diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-11-26 23:09:48 +0100 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-11-26 23:09:48 +0100 |
commit | 84d65a8776acb5f10ef4705c752d4e55b0250577 (patch) | |
tree | 770c56dee2dce9a544a404cad9fb42bf213f9883 /src/library | |
parent | 50d5d0f1dd3901c82d40628083c9e386f3e22f99 (diff) | |
parent | a1821697487af507b9387aaf68bc8faef5ab7220 (diff) | |
download | scala-84d65a8776acb5f10ef4705c752d4e55b0250577.tar.gz scala-84d65a8776acb5f10ef4705c752d4e55b0250577.tar.bz2 scala-84d65a8776acb5f10ef4705c752d4e55b0250577.zip |
Merge pull request #4157 from Ichoran/issue/8814
SI-8814 mutable.LongMap loses its LongMapness when adding with +
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/mutable/AnyRefMap.scala | 18 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/LongMap.scala | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/AnyRefMap.scala b/src/library/scala/collection/mutable/AnyRefMap.scala index 47fb66744e..2c7e76c5f5 100644 --- a/src/library/scala/collection/mutable/AnyRefMap.scala +++ b/src/library/scala/collection/mutable/AnyRefMap.scala @@ -335,6 +335,24 @@ extends AbstractMap[K, V] arm } + override def +[V1 >: V](kv: (K, V1)): AnyRefMap[K, V1] = { + val arm = clone().asInstanceOf[AnyRefMap[K, V1]] + arm += kv + arm + } + + override def ++[V1 >: V](xs: GenTraversableOnce[(K, V1)]): AnyRefMap[K, V1] = { + val arm = clone().asInstanceOf[AnyRefMap[K, V1]] + xs.foreach(kv => arm += kv) + arm + } + + override def updated[V1 >: V](key: K, value: V1): AnyRefMap[K, V1] = { + val arm = clone().asInstanceOf[AnyRefMap[K, V1]] + arm += (key, value) + arm + } + private[this] def foreachElement[A,B](elems: Array[AnyRef], f: A => B) { var i,j = 0 while (i < _hashes.length & j < _size) { diff --git a/src/library/scala/collection/mutable/LongMap.scala b/src/library/scala/collection/mutable/LongMap.scala index 4c24c036f9..eea33e3044 100644 --- a/src/library/scala/collection/mutable/LongMap.scala +++ b/src/library/scala/collection/mutable/LongMap.scala @@ -415,6 +415,24 @@ extends AbstractMap[Long, V] lm } + override def +[V1 >: V](kv: (Long, V1)): LongMap[V1] = { + val lm = clone().asInstanceOf[LongMap[V1]] + lm += kv + lm + } + + override def ++[V1 >: V](xs: GenTraversableOnce[(Long, V1)]): LongMap[V1] = { + val lm = clone().asInstanceOf[LongMap[V1]] + xs.foreach(kv => lm += kv) + lm + } + + override def updated[V1 >: V](key: Long, value: V1): LongMap[V1] = { + val lm = clone().asInstanceOf[LongMap[V1]] + lm += (key, value) + lm + } + /** Applies a function to all keys of this map. */ def foreachKey[A](f: Long => A) { if ((extraKeys & 1) == 1) f(0L) |