Scala Library
|
|
scala/collection/immutable/MapLike.scala
]
trait
MapLike[A, +B, +This <: MapLike[A, B, This] with
Map[A, B]]
extends
MapLike[A, B, This]
A generic template for immutable maps from keys of type A
to values of type B
.
To implement a concrete map, you need to provide implementations of the
following methods (where This
is the type of the map in
question):
def get(key: A): Option[B] def iterator: Iterator[(A, B)] def + [B1 >: B](kv: (A, B)): Map[A, B1] def - (key: A): This
If you wish that methods like
, take
, drop
,
filter
return the same kind of map, you should also override:
def empty: This
It is also good idea to override methods foreach
and
size
for efficiency.
Method Summary | |
override def
|
+
[B1 >: B](elem1 : (A, B1), elem2 : (A, B1), elems : (A, B1)*) : Map[A, B1]
Adds two or more elements to this collection and returns
a new collection.
|
abstract def
|
+
[B1 >: B](kv : (A, B1)) : Map[A, B1]
Add a key/value pair to this map, returning a new map.
|
override def
|
++
[B1 >: B](iter : Iterator[(A, B1)]) : Map[A, B1]
Adds a number of elements provided by an iterator
and returns a new collection with the added elements.
|
override def
|
++
[B1 >: B](elems : Traversable[(A, B1)]) : Map[A, B1]
Adds a number of elements provided by a traversable object
and returns a new collection with the added elements.
|
override def
|
filterNot
(p : ((A, B)) => Boolean) : This
Returns a new map with all key/value pairs for which the predicate
p returns true . |
def
|
transform
[C, That](f : (A, B) => C)(implicit bf : CanBuildFrom[This, (A, C), That]) : That
This function transforms all the values of mappings contained
in this map with function
f . |
def
|
update [B1 >: B](key : A, value : B1) : Map[A, B1] |
override def
|
updated
[B1 >: B](key : A, value : B1) : Map[A, B1]
A new immutable map containing updating this map with a given key/value mapping.
|
Methods inherited from MapLike | |
empty (abstract), get (abstract), iterator (abstract), - (abstract), newBuilder, isEmpty, getOrElse, apply, contains, isDefinedAt, keySet, keysIterator, keys, valuesIterable, valuesIterator, values, default, filterKeys, mapValues, mapElements, addString, stringPrefix, toString, hashCode, equals |
Methods inherited from Subtractable | |
-, --, -- |
Methods inherited from IterableLike | |
thisCollection, toCollection, elements, foreach, forall, exists, find, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, view, view, first, firstOption, projection |
Methods inherited from TraversableLike | |
repr, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toSeq, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, withFilter |
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 |
Method Details |
key -
the keyvalue -
the valuekv -
the key/value pairelem1 -
the first element to add.elem2 -
the second element to add.elems -
the remaining elements to add.elems -
the traversable object.iter -
the iteratorf
.f -
A function over keys and valuesp
returns true
.p -
A predicate over key-value pairsfilter
with a negated predicate instead.
Scala Library
|
|