Permalink
Browse files

mutable.MapLike: override $mapNote to reflect actual require mutable api

The api needed to define a mutable.Map is different then the one
needed to define an immutable.Map. Prior to this patch the mutable one
reflected the api needed for the immutable one causing confusion about
what really needed to be defined.
  • Loading branch information...
srp committed May 15, 2012
1 parent f865e3b commit cb7655df50df7a8c14848687ee43a5a69ad802dc
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/library/scala/collection/mutable/MapLike.scala
@@ -18,6 +18,28 @@ import parallel.mutable.ParMap
* $mapNote
* $mapTags
* @since 2.8
*
* @define mapNote
* '''Implementation note:'''
* This trait provides most of the operations of a mutable `Map`
* independently of its representation. It is typically inherited by
* concrete implementations of maps.
*
* To implement a concrete mutable map, you need to provide
* implementations of the following methods:
* {{{
* def get(key: A): Option[B]
* def iterator: Iterator[(A, B)]
* def += (kv: (A, B)): This
* def -= (key: A): This
* }}}
* If you wish that methods like `take`, `drop`, `filter` also return the same kind of map
* you should also override:
* {{{
* def empty: This
* }}}
* It is also good idea to override methods `foreach` and
* `size` for efficiency.
*/
trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]]
extends scala.collection.MapLike[A, B, This]

0 comments on commit cb7655d

Please sign in to comment.