diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-03-15 11:03:03 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-03-15 11:03:03 +0000 |
commit | 2f0a415e1fd1ed856808238e288039b5909b6cbe (patch) | |
tree | 22ce726a59397767879a5491f3b3c8954fe39f0a | |
parent | 2ccf6d3b00d34176e100dd1b87f70182e79d5b93 (diff) | |
download | scala-2f0a415e1fd1ed856808238e288039b5909b6cbe.tar.gz scala-2f0a415e1fd1ed856808238e288039b5909b6cbe.tar.bz2 scala-2f0a415e1fd1ed856808238e288039b5909b6cbe.zip |
Fixes #3132. No review necessary.
4 files changed, 19 insertions, 9 deletions
diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala index 7af138067b..0059ab1fca 100644 --- a/src/library/scala/collection/JavaConversions.scala +++ b/src/library/scala/collection/JavaConversions.scala @@ -497,9 +497,10 @@ object JavaConversions { case class MutableMapWrapper[A, B](underlying : mutable.Map[A, B])(m : ClassManifest[A]) extends MutableMapWrapperLike[A, B](underlying)(m) - abstract class JMapWrapperLike[A, B, +Repr <: mutable.MapLike[A, B, Repr] with mutable.Map[A, B]] - (underlying: ju.Map[A, B]) + trait JMapWrapperLike[A, B, +Repr <: mutable.MapLike[A, B, Repr] with mutable.Map[A, B]] extends mutable.Map[A, B] with mutable.MapLike[A, B, Repr] { + def underlying: ju.Map[A, B] + override def size = underlying.size def get(k : A) = { @@ -538,8 +539,8 @@ object JavaConversions { override def empty: Repr = null.asInstanceOf[Repr] } - case class JMapWrapper[A, B](underlying : ju.Map[A, B]) - extends JMapWrapperLike[A, B, JMapWrapper[A, B]](underlying) { + case class JMapWrapper[A, B](val underlying : ju.Map[A, B]) + extends JMapWrapperLike[A, B, JMapWrapper[A, B]] { override def empty = JMapWrapper(new ju.HashMap[A, B]) } @@ -584,8 +585,8 @@ object JavaConversions { } - case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) - extends JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]](underlying) with mutable.ConcurrentMap[A, B] { + case class JConcurrentMapWrapper[A, B](val underlying: juc.ConcurrentMap[A, B]) + extends JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with mutable.ConcurrentMap[A, B] { override def get(k: A) = { val v = underlying.get(k) if (v != null) Some(v) diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 2752f29c00..29d3c874f6 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -849,7 +849,7 @@ self => b.result } - /** Spits this $coll into a prefix/suffix pair according to a predicate. + /** Splits this $coll into a prefix/suffix pair according to a predicate. * * Note: `c span p` is equivalent to (but possibly more efficient than) * `(c takeWhile p, c dropWhile p)`, provided the evaluation of the predicate `p` diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala index 4f2eb40a64..c2668b48a2 100644 --- a/src/library/scala/collection/generic/TraversableFactory.scala +++ b/src/library/scala/collection/generic/TraversableFactory.scala @@ -38,7 +38,7 @@ abstract class TraversableFactory[CC[X] <: Traversable[X] with GenericTraversabl extends GenericCompanion[CC] { /** A generic implementation of the `CanBuildFrom` trait, which forwards - * all calls to `apply(from)` to the `genericBuilder` methof of + * all calls to `apply(from)` to the `genericBuilder` method of * $coll `from`, and which forwards all calls of `apply()` to the * `newBuilder` method of this factory. */ diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala index 81c91dec3d..cad4dc2e43 100644 --- a/src/library/scala/collection/mutable/WeakHashMap.scala +++ b/src/library/scala/collection/mutable/WeakHashMap.scala @@ -13,10 +13,19 @@ package scala.collection package mutable import JavaConversions._ +import generic._ + /** * @since 2.8 */ -class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap) { +class WeakHashMap[A, B] extends JMapWrapper[A, B](new java.util.WeakHashMap) + with JMapWrapperLike[A, B, WeakHashMap[A, B]] { override def empty = new WeakHashMap[A, B] } + +object WeakHashMap extends MutableMapFactory[WeakHashMap] { + implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), WeakHashMap[A, B]] = new MapCanBuildFrom[A, B] + def empty[A, B]: WeakHashMap[A, B] = new WeakHashMap[A, B] +} + |