Fixes #3132. No review necessary.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@21175 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
prokopec 2010-03-15 11:03:03 +00:00
parent 04b6bef15d
commit 9fd90b30ac
4 changed files with 19 additions and 9 deletions

View File

@ -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)

View File

@ -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`

View File

@ -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.
*/

View File

@ -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]
}