Scala Library
|
|
scala/collection/Map.scala
]
trait
Map[A, +B]
extends
Iterable[(A, B)] with
MapTemplate[A, B, Map[A, B]]
A map 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, B1)): This 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 might also be a good idea to override methods foreach
and size
for efficiency.
DefaultMap
instead.MapTemplate
as well.Method Summary | |
def
|
empty : Map[A, B] |
Methods inherited from MapTemplate | |
get (abstract), iterator (abstract), + (abstract), - (abstract), newBuilder, isEmpty, getOrElse, apply, contains, isDefinedAt, keySet, keysIterator, keys, valueIterable, valuesIterator, values, default, filterKeys, mapValues, mapElements, updated, +, ++, ++, addString, equals, stringPrefix, toString |
Methods inherited from Subtractable | |
-, --, -- |
Methods inherited from PartialFunction | |
orElse, andThen |
Methods inherited from Function1 | |
compose |
Methods inherited from Iterable | |
companion |
Methods inherited from IterableTemplate | |
elements, foreach, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection |
Methods inherited from TraversableClass | |
genericBuilder, unzip, flatten, transpose |
Methods inherited from TraversableTemplate | |
thisCollection, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSequence, toSet, mkString, mkString, mkString, addString, addString |
Methods inherited from AnyRef | |
getClass, hashCode, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Method Details |
Scala Library
|
|