scala.collection.immutable

trait Map

[source: scala/collection/immutable/Map.scala]

trait Map[A, +B]
extends Map[A, B]

This class defines the interface for immutable maps. Operations on an immutable map leave the original map unchanged, and return a new map if needed.

Concrete map implementations have to provide functionality for the abstract methods in scala.collection.Map as well as for factory, update, and -.

Author
Matthias Zenger
Erik Stenman
Martin Odersky
Version
1.2, 31/06/2006
Direct Known Subclasses:
EmptyMap, HashMap, ListMap, Map1, Map2, Map3, Map4, SortedMap, UnbalancedTreeMap

Method Summary
def + [B1 >: B](kv1 : (A, B1), kv2 : (A, B1), kvs : (A, B1)*) : Map[A, B1]
Add two or more key/value pairs to this map.
def + (key : A) : MapTo

This method defines syntactic sugar for adding a mapping. It is typically used in the following way:

      map + key -> value
    
def + [B1 >: B](kv : (A, B1)) : Map[A, B1]
Add a key/value pair to this map.
def ++ [B1 >: B](kvs : Iterable[(A, B1)]) : Map[A, B1]
Add a sequence of key/value pairs to this map.
def ++ [B1 >: B](kvs : Iterator[(A, B1)]) : Map[A, B1]
Add a sequence of key/value pairs to this map.
abstract def - (key : A) : Map[A, B]
Remove a key from this map
def - (key1 : A, key2 : A, keys : A*) : Map[A, B]
Remove two or more keys from this map
def -- (keys : Iterator[A]) : Map[A, B]
Remove a sequence of keys from this map
def -- (keys : Iterable[A]) : Map[A, B]
Remove a sequence of keys from this map
abstract def empty [C] : Map[A, C]
This method returns a new map instance of the same class mapping keys of the same type to values of type C.
def excl (keys : Iterable[A]) : Map[A, B]
This method removes all the mappings for keys provided by an iterator over the elements of the keys object.
def excl (keys : A*) : Map[A, B]
This method will return a map where all the mappings for the given sequence of keys are removed from the map.
override def filter (p : ((A, B)) => Boolean) : Map[A, B]
This method removes all the mappings for which the predicate p returns false.
def incl [B1 >: B](mappings : (A, B1)*) : Map[A, B1]
incl can be used to add many mappings at the same time to the map. The method assumes that a mapping is represented by a Pair object who's first component denotes the key, and who's second component refers to the value.
def incl [B1 >: B](map : Iterable[(A, B1)]) : Map[A, B1]
incl can be used to add many mappings at the same time to the map. The method assumes that each mapping is represented by an Iterator over Pair objects who's first component denotes the key, and who's second component refers to the value.
def mappingToString [B1 >: B](p : (A, B1)) : String
This method controls how a mapping is represented in the string representation provided by method toString.
def transform [C](f : (A, B) => C) : Map[A, C]
This function transforms all the values of mappings contained in this map with function f.
abstract def update [B1 >: B](key : A, value : B1) : Map[A, B1]
This method allows one to create a new map with an additional mapping from key to value. If the map contains already a mapping for key, it will be overridden by this function.
def withDefault [B1 >: B](d : (A) => B1) : Map[A, B1]
The same map with a given default function
def withDefaultValue [B1 >: B](d : B1) : Map[A, B1]
The same map with a given default value
Methods inherited from Map
size (abstract), get (abstract), getOrElse, isEmpty, apply, contains, isDefinedAt, keys, keySet, values, equals, hashCode, toString, default, projection, filterKeys, mapElements
Methods inherited from Collection
toArray, stringPrefix
Methods inherited from Iterable
elements (abstract), concat, ++, map, flatMap, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, mkString, mkString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
class MapTo (key : A) extends AnyRef