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` | + (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](kv1 : (A, B1), kv2 : (A, B1), kvs : (A, B1)*) : Map[A, B1] Add two or more key/value pairs 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 : 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.
`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.
`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

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, 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

Method Details

`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`.

`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.

Parameters
  `key -` ...
  `value -` ...
Returns
  the created map
Deprecated
  use `+({A, B})` instead

`` `def` +[B1 >: B](kv : (A, B1)) : Map[A, B1]

  Add a key/value pair to this map.

Parameters
  `kv -` the key/value pair.
Returns
  A new map with the new binding added to this map

`` `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.

Parameters
  `kv1 -` the first key/value pair.
  `kv2 -` the second key/value pair.
  `kvs -` the remaining key/value pairs.
Returns
  A new map with the new bindings added

`` `def` ++[B1 >: B](kvs : Iterable[(A, B1)]) : Map[A, B1]

  Add a sequence of key/value pairs to this map.

Parameters
  `kvs -` the iterable object containing all key/value pairs.
Returns
  A new map with the new bindings added

`` `def` ++[B1 >: B](kvs : Iterator[(A, B1)]) : Map[A, B1]

  Add a sequence of key/value pairs to this map.

Parameters
  `kvs -` the iterator containing all key/value pairs.
Returns
  A new map with the new bindings added

`abstract` `def` -(key : A) : Map[A, B]

  Remove a key from this map

Parameters
  `key -` the key to be removed
Returns
  If the map does not contain a binding for `key` it is returned unchanged. Otherwise, return a new map without a binding for `key`

`` `def` -(key1 : A, key2 : A, keys : A*) : Map[A, B]

  Remove two or more keys from this map

Parameters
  `key1 -` the first key to be removed
  `key2 -` the second key to be removed
  `keys -` the remaining keys to be removed
Returns
  A map without bindings for `keys` If the map is mutable, the bindings are removed in place and the map itself is returned. If the map is immutable, a new map with the bindings removed is returned.

`` `def` --(keys : Iterable[A]) : Map[A, B]

  Remove a sequence of keys from this map

Parameters
  `keys -` the keys to be removed
Returns
  A map without bindings for the given keys. If the map is mutable, the bindings are removed in place and the map itself is returned. If the map is immutable, a new map with the bindings removed is returned.

`` `def` --(keys : Iterator[A]) : Map[A, B]

  Remove a sequence of keys from this map

Parameters
  `keys -` the keys to be removed
Returns
  A map without bindings for the given keys. If the map is mutable, the bindings are removed in place and the map itself is returned. If the map is immutable, a new map with the bindings removed is returned.

`` `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

`` `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`.

Parameters
  `f -` A function over keys and values
Returns
  the updated map

`override` `def` filter(p : ((A, B)) => Boolean) : Map[A, B]

  This method removes all the mappings for which the predicate `p` returns `false`.

Parameters
  `p -` A prediacte over key-value pairs
Returns
  the updated map

@deprecated
`` `def` +(key : A) : MapTo

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

            map + key -> value

Deprecated
  use `+({A, B})` instead

@deprecated
`` `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.

Parameters
  `mappings -` ...
Returns
  ...
Deprecated
  use `+` instead

@deprecated
`` `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.

Deprecated
  use `++` instead

@deprecated
`` `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.

Parameters
  `keys -` ...
Returns
  the updated map
Deprecated
  use `-` instead

@deprecated
`` `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.

Parameters
  `keys -` ...
Returns
  the updated map
Deprecated
  use `--` instead

@deprecated
`` `def` mappingToString[B1 >: B](p : (A, B1)) : String

  This method controls how a mapping is represented in the string representation provided by method `toString`.

Parameters
  `p -` ...
Returns
  the string representation of a map entry