scala.collection.immutable

class ListMap

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

@serializable

@SerialVersionUID(301002838095710379L)

class ListMap[A, +B]
extends Map[A, B] with MapLike[A, B, ListMap[A, B]]
This class implements immutable maps using a list-based data structure. Instances of ListMap represent empty maps; they can be either created by calling the constructor directly, or by applying the function ListMap.empty.
Author
Matthias Zenger
Martin Oderskty
Version
2.0, 01/01/2007
Since
1
Direct Known Subclasses:
ListMap.Node

Method Summary
override def + [B1 >: B](elem1 : (A, B1), elem2 : (A, B1), elems : (A, B1)*) : ListMap[A, B1]
Adds two or more elements to this collection and returns either the collection itself (if it is mutable), or a new collection with the added elements.
def + [B1 >: B](kv : (A, B1)) : ListMap[A, B1]
Add a key/value pair to this map.
def - (key : A) : ListMap[A, B]
This creates a new mapping without the given key. If the map does not contain a mapping for the given key, the method returns the same map.
override def empty : ListMap[A, Nothing]
def get (key : A) : Option[B]
Checks if this map maps key to a value and return the value if it exists.
def iterator : Iterator[(A, B)]
Returns an iterator over key-value pairs.
protected def key : A
protected def next : ListMap[A, B]
override def size : Int
Returns the number of mappings in this map.
override def updated [B1 >: B](key : A, value : B1) : ListMap[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.
protected def value : B
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, default, 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
Class Summary
protected class Node [B1 >: B](protected val override key : A, protected val override value : B1) extends ListMap[A, B1]
Method Details
override def empty : ListMap[A, Nothing]
Overrides
Map.empty

override def size : Int
Returns the number of mappings in this map.
Returns
number of mappings in this map.

def get(key : A) : Option[B]
Checks 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 updated[B1 >: B](key : A, value : B1) : ListMap[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.
Parameters
key - the key element of the updated entry.
value - the value element of the updated entry.
Overrides
Map.updated, MapLike.updated

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

override def +[B1 >: B](elem1 : (A, B1), elem2 : (A, B1), elems : (A, B1)*) : ListMap[A, B1]
Adds two or more elements to this collection and returns either the collection itself (if it is mutable), or a new collection with the added elements.
Parameters
elem1 - the first element to add.
elem2 - the second element to add.
elems - the remaining elements to add.
Overrides
MapLike.+

def -(key : A) : ListMap[A, B]
This creates a new mapping without the given key. If the map does not contain a mapping for the given key, the method returns the same map.
Parameters
key - a map without a mapping for the given key.

def iterator : Iterator[(A, B)]
Returns an iterator over key-value pairs.

protected def key : A

protected def value : B

protected def next : ListMap[A, B]