scala.collection.immutable

class TreeMap

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

@serializable

class TreeMap[A, +B](val size : Int, t : Tree[B], implicit view$4 : (A) => Ordered[A])
extends RedBlack[A] with SortedMap[A, B]
This class implements immutable maps using a tree.
Author
Erik Stenman
Matthias Zenger
Version
1.1, 03/05/2004
Additional Constructor Summary
def this ()(implicit view$5 : (A) => Ordered[A]) : TreeMap[A, B]
Value Summary
protected val tree : Tree[B]
Method Summary
def - (key : A) : TreeMap[A, B]
Remove a key from this map
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.
override def compare (k0 : A, k1 : A) : Int
Comparison function that orders keys.
def elements : Iterator[(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 exists (f : ((A, B)) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
override def firstKey : A
Returns the first key of the collection.
override def forall (f : ((A, B)) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff the predicate yields true for all elements.
override def foreach (f : ((A, B)) => Unit) : Unit
Apply a function f to all elements of this iterable object.
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 [B1 >: B](key : A, value : B1) : TreeMap[A, B1]
A new TreeMap with the entry added is returned, assuming that key is not in the TreeMap.
def isSmaller (x : A, y : A) : Boolean
override def lastKey : A
Returns the last key of the collection.
override def rangeImpl (from : Option[A], until : Option[A]) : SortedMap[A, B]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Keys are garuanteed to be consistent between the collection and its projection.
def update [B1 >: B](key : A, value : B1) : TreeMap[A, B1]
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 SortedMap
from, until, range, +, +, ++, ++, -, --, --, transform, filter
Methods inherited from SortedMap
keySet
Methods inherited from Sorted
to, hasAll
Methods inherited from Map
withDefault, withDefaultValue, +, incl, incl, excl, excl, mappingToString
Methods inherited from Map
getOrElse, isEmpty, contains, isDefinedAt, keys, values, equals, hashCode, toString, default, projection, filterKeys, mapElements, stringPrefix
Methods inherited from Collection
toArray
Methods inherited from Iterable
concat, ++, map, flatMap, partition, takeWhile, dropWhile, take, drop, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toSeq, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Additional Constructor Details
def this()(implicit view$5 : (A) => Ordered[A]) : TreeMap[A, B]

Value Details
protected val tree : Tree[B]

Method Details
def isSmaller(x : A, y : A) : Boolean
Overrides
RedBlack.isSmaller

override def rangeImpl(from : Option[A], until : Option[A]) : SortedMap[A, B]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Keys are garuanteed to be consistent between the collection and its projection.
Parameters
from - The lower-bound (inclusive) of the ranged projection. None if there is no lower bound.
until - The upper-bound (exclusive) of the ranged projection. None if there is no upper bound.
Overrides
SortedMap.rangeImpl

override def firstKey : A
Returns the first key of the collection.

override def lastKey : A
Returns the last key of the collection.

override def compare(k0 : A, k1 : A) : Int
Comparison function that orders keys.

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

def update[B1 >: B](key : A, value : B1) : TreeMap[A, B1]
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.
Parameters
key - ...
value - ...
Returns
...
Overrides
SortedMap.update

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

def -(key : A) : TreeMap[A, B]
Remove a key from this map
Parameters
key - the key to be removed
Returns
If the map does not contain a binding for key it is returned unchanged. Otherwise, return a new map without a binding for key
Overrides
SortedMap.-

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

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").

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

override def foreach(f : ((A, B)) => Unit) : Unit
Apply a function f to all elements of this iterable object.
Notes
Will not terminate for infinite-sized collections.
Parameters
f - a function that is applied to every element.

override def forall(f : ((A, B)) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff the predicate yields true for all elements.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
true, iff the predicate yields true for all elements.

override def exists(f : ((A, B)) => Boolean) : Boolean
Apply a predicate p to all elements of this iterable object and return true, iff there is at least one element for which p yields true.
Notes
May not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
true, iff the predicate yields true for at least one element.