scala.collection.immutable.Map

class WithDefault

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

class WithDefault[A, +B](underlying : Map[A, B], d : (A) => B)
extends Map[A, B]
Method Summary
def + [B1 >: B](kv : (A, B1)) : WithDefault[A, B1]
Add a key/value pair to this map, returning a new map.
def - (key : A) : WithDefault[A, B]
Removes a key from this map, returning a new map
override def default (key : A) : B
The default value for the map, returned when a key is not found The method implemented here yields an error, but it might be overridden in subclasses.
override def empty : WithDefault[A, B]
def get (key : A) : Option[B]
Check if this map maps key to a value and return the value as an option if it exists, None if not.
def iterator : Iterator[(A, B)]
An iterator yielding all key/value mappings of this map.
override def size : Int
The number of elements in this collection
override def updated [B1 >: B](key : A, value : B1) : WithDefault[A, B1]
Add a key/value pair to this map.
Methods inherited from Map
withDefault, withDefaultValue
Methods inherited from MapLike
+, ++, ++, transform, filterNot, update
Methods inherited from MapLike
newBuilder, isEmpty, getOrElse, apply, contains, isDefinedAt, keySet, keysIterator, keys, valuesIterable, valuesIterator, values, filterKeys, mapValues, mapElements, addString, stringPrefix, toString, hashCode, equals
Methods inherited from Subtractable
-, --, --
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from Iterable
companion
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 GenericTraversableTemplate
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, 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 AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override def size : Int
The number of elements in this collection

def get(key : A) : Option[B]
Check if this map maps key to a value and return the value as an option if it exists, None if not.
Parameters
key - the key of the mapping of interest.
Returns
the value of the mapping as an option, if it exists, or None.

def iterator : Iterator[(A, B)]
An iterator yielding all key/value mappings of this map.

override def empty : WithDefault[A, B]
Overrides
Map.empty

override def updated[B1 >: B](key : A, value : B1) : WithDefault[A, B1]
Add a key/value pair to this map.
Parameters
key - the key
value - the value
Returns
A new map with the new binding added to this map
Overrides
Map.updated

def +[B1 >: B](kv : (A, B1)) : WithDefault[A, B1]
Add a key/value pair to this map, returning a new map.
Parameters
kv - the key/value pair
Returns
A new map with the new binding added to this map
Overrides
Map.+

def -(key : A) : WithDefault[A, B]
Removes a key from this map, returning a new map
Parameters
key - the key to be removed
Returns
A new map without a binding for key

override def default(key : A) : B
The default value for the map, returned when a key is not found The method implemented here yields an error, but it might be overridden in subclasses.
Parameters
key - the given key value
Throws
Predef.NoSuchElementException -