diff options
author | Matthias Zenger <mzenger@gmail.com> | 2003-07-09 15:33:03 +0000 |
---|---|---|
committer | Matthias Zenger <mzenger@gmail.com> | 2003-07-09 15:33:03 +0000 |
commit | 1203341cb21b8f29208ac9bab15da34906bde96e (patch) | |
tree | 80c1043c9794208b9996f2aa4c929d744ecb31ef | |
parent | 2f2e78b7c135019758feee714c25f9e43b17bdca (diff) | |
download | scala-1203341cb21b8f29208ac9bab15da34906bde96e.tar.gz scala-1203341cb21b8f29208ac9bab15da34906bde96e.tar.bz2 scala-1203341cb21b8f29208ac9bab15da34906bde96e.zip |
Changed some names.
-rw-r--r-- | sources/scala/collection/immutable/Map.scala | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sources/scala/collection/immutable/Map.scala b/sources/scala/collection/immutable/Map.scala index 10e3b7b733..7f181884fb 100644 --- a/sources/scala/collection/immutable/Map.scala +++ b/sources/scala/collection/immutable/Map.scala @@ -10,17 +10,28 @@ package scala.collection.immutable; -trait Map[A, B, This <: scala.collection.immutable.Map[A, B, This]]: This with scala.collection.Map[A, B] { +trait Map[A, B, This <: Map[A, B, This]]: This with scala.collection.Map[A, B] { def update(key: A, value: B): This; - def remove(key: A): This; + def -(key: A): This; - def clear: This; + def remove(keys: A*): This = removeElems(keys); - def put(mappings: Pair[A, B]*): This = putMap(mappings); + def removeElems(keys: Iterable[A]): This = { + val iter = keys.elements; + var res = this; + while (iter.hasNext) { + res = res - iter.next; + } + res; + } - def putMap(map: Iterable[Pair[A, B]]): This = { + def +(key: A): MapTo = new MapTo(key); + + def add(mappings: Pair[A, B]*): This = addElems(mappings); + + def addElems(map: Iterable[Pair[A, B]]): This = { val iter = map.elements; var res = this; while (iter.hasNext) { @@ -60,4 +71,8 @@ trait Map[A, B, This <: scala.collection.immutable.Map[A, B, This]]: This with s } + "}"; def mappingToString(p: Pair[A, B]) = p._1.toString() + " -> " + p._2; + + class MapTo(key: A) { + def ->(value: B): This = update(key, value); + } } |