summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala16
-rw-r--r--src/library/scala/collection/immutable/LongMap.scala25
-rw-r--r--test/files/run/t3603.scala18
3 files changed, 57 insertions, 2 deletions
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index ba5cd896ac..d4605d3e1f 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -11,6 +11,14 @@
package scala.collection
package immutable;
+
+
+import scala.collection.generic.CanBuildFrom
+import scala.collection.mutable.Builder
+import scala.collection.mutable.MapBuilder
+
+
+
/** Utility class for integer maps.
* @author David MacIver
*/
@@ -53,6 +61,12 @@ import IntMapUtils._
* @since 2.7
*/
object IntMap {
+ /** $mapCanBuildFromInfo */
+ implicit def canBuildFrom[A, B] = new CanBuildFrom[IntMap[A], (Int, B), IntMap[B]] {
+ def apply(from: IntMap[A]): Builder[(Int, B), IntMap[B]] = apply()
+ def apply(): Builder[(Int, B), IntMap[B]] = new MapBuilder[Int, B, IntMap[B]](empty[B])
+ }
+
def empty[T] : IntMap[T] = IntMap.Nil;
def singleton[T](key : Int, value : T) : IntMap[T] = IntMap.Tip(key, value);
def apply[T](elems : (Int, T)*) : IntMap[T] =
@@ -147,7 +161,7 @@ import IntMap._
/** Specialised immutable map structure for integer keys, based on
* <a href="http://citeseer.ist.psu.edu/okasaki98fast.html">Fast Mergeable Integer Maps</a>
- * by Okasaki and Gill. Essentially a trie based on binary digits of the the integers.
+ * by Okasaki and Gill. Essentially a trie based on binary digits of the integers.
*
* Note: This class is as of 2.8 largely superseded by HashMap.
*
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index 691a81d9f0..dcdc6e948f 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -1,6 +1,23 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2010, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+
+
package scala.collection
package immutable
+
+import scala.collection.generic.CanBuildFrom
+import scala.collection.mutable.Builder
+import scala.collection.mutable.MapBuilder
+
+
+
/** Utility class for long maps.
* @author David MacIver
*/
@@ -44,6 +61,12 @@ import LongMapUtils._
* @since 2.7
*/
object LongMap{
+ /** $mapCanBuildFromInfo */
+ implicit def canBuildFrom[A, B] = new CanBuildFrom[LongMap[A], (Long, B), LongMap[B]] {
+ def apply(from: LongMap[A]): Builder[(Long, B), LongMap[B]] = apply()
+ def apply(): Builder[(Long, B), LongMap[B]] = new MapBuilder[Long, B, LongMap[B]](empty[B])
+ }
+
def empty[T] : LongMap[T] = LongMap.Nil;
def singleton[T](key : Long, value : T) : LongMap[T] = LongMap.Tip(key, value);
def apply[T](elems : (Long, T)*) : LongMap[T] =
@@ -136,7 +159,7 @@ import LongMap._;
/**
* Specialised immutable map structure for long keys, based on
* <a href="http://citeseer.ist.psu.edu/okasaki98fast.html">Fast Mergeable Long Maps</a>
- * by Okasaki and Gill. Essentially a trie based on binary digits of the the integers.
+ * by Okasaki and Gill. Essentially a trie based on binary digits of the integers.
*
* Note: This class is as of 2.8 largely superseded by HashMap.
*
diff --git a/test/files/run/t3603.scala b/test/files/run/t3603.scala
new file mode 100644
index 0000000000..a89cb7080a
--- /dev/null
+++ b/test/files/run/t3603.scala
@@ -0,0 +1,18 @@
+
+
+
+object Test {
+
+ def main(args: Array[String]) {
+ import collection.immutable._
+
+ val intmap = IntMap(1 -> 1, 2 -> 2)
+ val intres = intmap.map { case (a, b) => (a, b.toString) }
+ assert(intres.isInstanceOf[IntMap[_]])
+
+ val longmap = LongMap(1L -> 1, 2L -> 2)
+ val longres = longmap.map { case (a, b) => (a, b.toString) }
+ assert(longres.isInstanceOf[LongMap[_]])
+ }
+
+}