diff options
author | Martin Odersky <odersky@gmail.com> | 2009-05-14 17:30:15 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-05-14 17:30:15 +0000 |
commit | 5b4ff1bb32bd855f4ca5a5ac4b37e288ad35c5be (patch) | |
tree | 597ab1d3e621e91db8b1273f7337b73a440959d8 /src/library/scala/collection/generic/MutableMapTemplate.scala | |
parent | 083f2fe49e8b01c8e886b0656dcc76bce017974f (diff) | |
download | scala-5b4ff1bb32bd855f4ca5a5ac4b37e288ad35c5be.tar.gz scala-5b4ff1bb32bd855f4ca5a5ac4b37e288ad35c5be.tar.bz2 scala-5b4ff1bb32bd855f4ca5a5ac4b37e288ad35c5be.zip |
more collection cleanups and better docs
Diffstat (limited to 'src/library/scala/collection/generic/MutableMapTemplate.scala')
-rw-r--r-- | src/library/scala/collection/generic/MutableMapTemplate.scala | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/library/scala/collection/generic/MutableMapTemplate.scala b/src/library/scala/collection/generic/MutableMapTemplate.scala index d7efc0bd0a..9ccb13787b 100644 --- a/src/library/scala/collection/generic/MutableMapTemplate.scala +++ b/src/library/scala/collection/generic/MutableMapTemplate.scala @@ -37,7 +37,10 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta with Cloneable[This] { self => - override protected[this] def newBuilder: Builder[(A, B), This] = new MutableMapBuilder[A, B, This](empty.asInstanceOf[This]) // !!! concrete overrides abstract problem + /** A common implementation of `newBuilder` for all mutable maps in terms of `empty`. + * Overrides `MapTemplate` implementation for better efficiency. + */ + override protected[this] def newBuilder: Builder[(A, B), This] = empty /** Adds a new mapping from <code>key</code> * to <code>value</code> to the map. If the map already contains a @@ -60,7 +63,7 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta * @return An option consisting of value associated previously associated with `key` in the map, * or None if `key` was not yet defined in the map. */ - def update(key: A, elem: B) { this += ((key, elem)) } + def update(key: A, value: B) { this += ((key, value)) } /** Add a new key/value mapping this map. * @param kv the key/value pair. @@ -195,6 +198,9 @@ trait MutableMapTemplate[A, B, +This <: MutableMapTemplate[A, B, This] with muta this } + /** @return the values of this map as a set */ + override def valueSet: immutable.Set[B] = immutable.Set.empty[B] ++ (self map (_._2)) + override def clone(): This = empty ++ thisCollection |