summaryrefslogtreecommitdiff
path: root/sources/scala/collection/immutable/Map.scala
diff options
context:
space:
mode:
authorMatthias Zenger <mzenger@gmail.com>2003-07-09 15:33:03 +0000
committerMatthias Zenger <mzenger@gmail.com>2003-07-09 15:33:03 +0000
commit1203341cb21b8f29208ac9bab15da34906bde96e (patch)
tree80c1043c9794208b9996f2aa4c929d744ecb31ef /sources/scala/collection/immutable/Map.scala
parent2f2e78b7c135019758feee714c25f9e43b17bdca (diff)
downloadscala-1203341cb21b8f29208ac9bab15da34906bde96e.tar.gz
scala-1203341cb21b8f29208ac9bab15da34906bde96e.tar.bz2
scala-1203341cb21b8f29208ac9bab15da34906bde96e.zip
Changed some names.
Diffstat (limited to 'sources/scala/collection/immutable/Map.scala')
-rw-r--r--sources/scala/collection/immutable/Map.scala25
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);
+ }
}