in scala.collection
trait Map

abstract trait Map [A, +B]
extends java.lang.Object
with scala.PartialFunction[A, B]
with scala.Iterable[scala.Tuple2[A, B]]
with scala.ScalaObject

This class defines the interface of collections that unambiguously map keys to values (i.e. a key is mapped to at least one value).

Class Map may only be used for accessing elements from map implementations. Two different extensions of class Map in the package scala.collection.mutable and scala.collection.immutable provide functionality for adding new key/value mappings to a map. The class in the first package is implemented by maps that are modified destructively, whereas the class in the second package is used by functional map implementations that rely on immutable data structures.

Author:
Matthias Zenger
Author:
Martin Odersky
Version:
1.2, 31/12/2006
Direct Known Subclasses:
Map, Map, MapProxy

Def Summary
def apply (key: A) : B
Retrieve the value which is associated with the given key. This method throws an exception if there is no mapping from the given key to a value.
def contains (key: A) : scala.Boolean
Is the given key mapped to a value by this map?
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 equals (that: scala.Any) : scala.Boolean
Compares two maps structurally; i.e. checks if all mappings contained in this map are also contained in the other map, and vice versa.
abstract def get (key: A) : scala.Option[B]
Check if this map maps key to a value and return the value if it exists.
override def hashCode : scala.Int
A hash method compatible with equals
def isDefinedAt (key: A) : scala.Boolean
Does this map contain a mapping from the given key to a value?
def isEmpty : scala.Boolean
Is this an empty map?
def keySet : java.lang.Object with scala.collection.Set[A]

def keys : scala.Iterator[A]
Creates an iterator for all keys.
abstract def size : scala.Int
Compute the number of key-to-value mappings.
override def toString : java.lang.String
Creates a string representation for this map.
def values : scala.Iterator[B]
Creates an iterator for a contained values.
Def inherited from scala.PartialFunction[A, B]
andThen , isDefinedAt, orElse
Def inherited from scala.Iterable[scala.Tuple2[A, B]]
++ , /:, :\, addString, concat, copyToBuffer, drop, dropWhile, elements, exists, filter, find, findIndexOf, flatMap, foldLeft, foldRight, forall, foreach, indexOf, map, mkString, mkString, reduceLeft, reduceRight, sameElements, take, takeWhile, toList
Def Detail
def apply (key: A): B
Retrieve the value which is associated with the given key. This method throws an exception if there is no mapping from the given key to a value.
Parameters:
key - the key
Returns:
the value associated with the given key.

def contains (key: A): scala.Boolean
Is the given key mapped to a value by this map?
Parameters:
key - the key
Returns:
true iff there is a mapping for key in this map

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 -

override def equals (that: scala.Any): scala.Boolean
Compares two maps structurally; i.e. checks if all mappings contained in this map are also contained in the other map, and vice versa.
Parameters:
that - the other map
Returns:
true iff both maps contain exactly the same mappings.

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

override def hashCode : scala.Int
A hash method compatible with equals

def isDefinedAt (key: A): scala.Boolean
Does this map contain a mapping from the given key to a value?
Parameters:
key - the key
Returns:
true iff there is a mapping for key in this map

def isEmpty : scala.Boolean
Is this an empty map?
Returns:
true iff the map is empty.

def keySet : java.lang.Object with scala.collection.Set[A]
Returns:
the keys of this map as a set.

def keys : scala.Iterator[A]
Creates an iterator for all keys.
Returns:
an iterator over all keys.

abstract def size : scala.Int
Compute the number of key-to-value mappings.
Returns:
the number of mappings

override def toString : java.lang.String
Creates a string representation for this map.
Returns:
a string showing all mappings

def values : scala.Iterator[B]
Creates an iterator for a contained values.
Returns:
an iterator over all values.