in scala/collection/immutable
class TreeMap

class TreeMap[A,B](view: (A) => Ordered[A])
extends Tree[A,Tuple2[A,B]]
with ScalaObject
with Map[A,B]

This class implements immutable maps using a tree.
Author:
Erik Stenman, Matthias Zenger
Version:
1.1, 03/05/2004

Field Summary
override type This
     The type returned when creating a new tree.

Method Summary
  def -(key: A): TreeMap[A,B]
     Removes the key from the TreeMap.
protected def New(sz: Int, t: GBTree[A,Tuple2[A,B]]): TreeMap[A,B]
     Creates a new TreeMap from a GBTree and its size.
override def apply(key: A): B
     Retrieve the value which is associated with the given key.
  def elements: Iterator[Tuple2[A,B]]
     Creates a new iterator over all elements contained in this object.
  def empty[C]: TreeMap[A,C]
     A factory to create empty maps of the same type of keys.
override def entryKey(entry: Tuple2[A,B]): A
     Returns the key of an entry.
override def equals(obj: Any): Boolean
     Compares two maps structurally; i.e.
override def get(key: A): Option[B]
     Check if this map maps key to a value and return the value if it exists.
  def insert(key: A, value: B): TreeMap[A,B]
     A new TreeMap with the entry added is returned, assuming that key is not in the TreeMap.
override def toList: List[Tuple2[A,B]]
     Creates a list of all (key, value) mappings.
  def update(key: A, value: B): TreeMap[A,B]
     A new TreeMap with the entry added is returned, if key is not in the TreeMap, otherwise the key is updated with the new entry.

Methods inherited from java/lang/Object-class
clone, eq, finalize, getClass, notify, notifyAll, synchronized, wait, wait, wait

Methods inherited from scala/Any-class
!=, ==, asInstanceOf, isInstanceOf, match

Methods inherited from scala/Iterable-class
/:, :\, exists, find, foldLeft, foldRight, forall, foreach, sameElements

Methods inherited from scala/collection/Map-class
contains, exists, forall, foreach, isDefinedAt, isEmpty, keys, values

Methods inherited from scala/collection/immutable/Map-class
+, MapTo, excl, excl, filter, hashCode, incl, incl, map, mappingToString, toString

Methods inherited from scala/collection/immutable/Tree-class
GBNil, INode, ITree, aNode, add, balance, balance_list, balance_list_1, delete_any, entries, findValue, is_defined, size, tree, update_or_add

Field Detail

This

  override type This = TreeMap[A,B]
The type returned when creating a new tree. This type should be defined by concrete implementations e.g.
   class C[T](...) extends Tree[A,B](...) {
     type This = C[T];
   
Method Detail

empty

  def empty[C]: TreeMap[A,C]
A factory to create empty maps of the same type of keys.

entryKey

  override def entryKey(entry: Tuple2[A,B]): A
Returns the key of an entry. This method has to be defined by concrete implementations of the class.

New

  protected def New(sz: Int, t: GBTree[A,Tuple2[A,B]]): TreeMap[A,B]
Creates a new TreeMap from a GBTree and its size.

update

  def update(key: A, value: B): TreeMap[A,B]
A new TreeMap with the entry added is returned, if key is not in the TreeMap, otherwise the key is updated with the new entry.

insert

  def insert(key: A, value: B): TreeMap[A,B]
A new TreeMap with the entry added is returned, assuming that key is not in the TreeMap.

-

  def -(key: A): TreeMap[A,B]
Removes the key from the TreeMap.

get

  override def get(key: A): 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

apply

  override 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.
Throws:
Error("key not found").

toList

  override def toList: List[Tuple2[A,B]]
Creates a list of all (key, value) mappings.
Returns:
the list of all mappings

elements

  def elements: Iterator[Tuple2[A,B]]
Creates a new iterator over all elements contained in this object.
Returns:
the new iterator

equals

  override def equals(obj: Any): 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.
Returns:
true, iff both maps contain exactly the same mappings.