Scala Library
|
|
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 -
.
Method Summary | |
def
|
+ (key : A) : MapTo |
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](kv : (A, B1)) : Map[A, B1]
Add a key/value pair to this map.
|
def
|
++
[B1 >: B](kvs : Iterator[(A, B1)]) : Map[A, B1]
Add a sequence of 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.
|
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 : Iterable[A]) : Map[A, B]
Remove a sequence of keys from this map
|
def
|
--
(keys : Iterator[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](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
|
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
|
mappingToString
[B1 >: B](p : (A, B1)) : java.lang.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, stringPrefix |
Methods inherited from Collection | |
toArray |
Methods inherited from Iterable | |
elements (abstract), concat, ++, map, flatMap, partition, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toSeq, toStream, mkString, mkString, mkString, addString, 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 |
C
.key
to value
. If the map contains already a
mapping for key
, it will be overridden by this
function.key -
...value -
...+({A, B})
insteadkv -
the key/value pair.kv1 -
the first key/value pair.kv2 -
the second key/value pair.kvs -
the remaining key/value pairs.kvs -
the iterable object containing all key/value pairs.kvs -
the iterator containing all key/value pairs.key -
the key to be removedkey
it is returned unchanged. Otherwise, return a new map
without a binding for key
key1 -
the first key to be removedkey2 -
the second key to be removedkeys -
the remaining keys to be removedkeys
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.keys -
the keys to be removedkeys -
the keys to be removedf
.f -
A function over keys and valuesp
returns false
.p -
A prediacte over key-value pairs
def
+(key : A) : MapTo
This method defines syntactic sugar for adding a mapping. It is typically used in the following way:
map + key -> value
+({A, B})
insteadincl
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.mappings -
...+
insteadincl
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.++
instead
def
excl(keys : A*) : Map[A, B]
keys -
...-
insteadkeys
object.keys -
...--
instead
def
mappingToString[B1 >: B](p : (A, B1)) : java.lang.String
toString
.p -
...
Scala Library
|
|