summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/immutable/TreeMap.scala
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-04-13 16:32:09 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-04-13 16:32:09 +0000
commit174c1721ff3b1b581142ad0ed80a655d2d0b4aba (patch)
tree9cf579b1d564dcd0f5d920b94a83663229986b06 /src/library/scala/collection/immutable/TreeMap.scala
parentbf0921a072c4761824365105c785dd5f2cf97588 (diff)
downloadscala-174c1721ff3b1b581142ad0ed80a655d2d0b4aba.tar.gz
scala-174c1721ff3b1b581142ad0ed80a655d2d0b4aba.tar.bz2
scala-174c1721ff3b1b581142ad0ed80a655d2d0b4aba.zip
Documented immutable.*. no review
Diffstat (limited to 'src/library/scala/collection/immutable/TreeMap.scala')
-rw-r--r--src/library/scala/collection/immutable/TreeMap.scala42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala
index bd04b8d2e2..61cfe2e13b 100644
--- a/src/library/scala/collection/immutable/TreeMap.scala
+++ b/src/library/scala/collection/immutable/TreeMap.scala
@@ -15,22 +15,33 @@ package immutable
import generic._
import mutable.Builder
-/** The canonical factory of <a href="TreeMap.html">TreeMap</a>'s.
- *
- * @since 1
+/** $factoryInfo
+ * @define Coll immutable.TreeMap
+ * @define coll immutable tree map
*/
object TreeMap extends ImmutableSortedMapFactory[TreeMap] {
def empty[A, B](implicit ord: Ordering[A]) = new TreeMap[A, B]()(ord)
+ /** $sortedMapCanBuildFromInfo */
implicit def canBuildFrom[A, B](implicit ord: Ordering[A]): CanBuildFrom[Coll, (A, B), TreeMap[A, B]] = new SortedMapCanBuildFrom[A, B]
private def make[A, B](s: Int, t: RedBlack[A]#Tree[B])(implicit ord: Ordering[A]) = new TreeMap[A, B](s, t)(ord)
}
/** This class implements immutable maps using a tree.
*
+ * @tparam A the type of the keys contained in this tree map.
+ * @tparam B the type of the values associated with the keys.
+ * @param ordering the implicit ordering used to compare objects of type `A`.
+ *
* @author Erik Stenman
* @author Matthias Zenger
* @version 1.1, 03/05/2004
* @since 1
+ * @define Coll immutable.TreeMap
+ * @define coll immutable tree map
+ * @define orderDependent
+ * @define orderDependentFold
+ * @define mayNotTerminateInf
+ * @define willNotTerminateInf
*/
@serializable
class TreeMap[A, +B](override val size: Int, t: RedBlack[A]#Tree[B])(implicit val ordering: Ordering[A])
@@ -65,18 +76,20 @@ class TreeMap[A, +B](override val size: Int, t: RedBlack[A]#Tree[B])(implicit va
* if key is <em>not</em> in the TreeMap, otherwise
* the key is updated with the new entry.
*
- * @param key ...
- * @param value ...
- * @return ...
+ * @tparam B1 type of the value of the new binding which is a supertype of `B`
+ * @param key the key that should be updated
+ * @param value the value to be associated with `key`
+ * @return a new $coll with the updated binding
*/
override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = {
val newsize = if (tree.lookup(key).isEmpty) size + 1 else size
TreeMap.make(newsize, tree.update(key, value))
}
- /** Add a key/value pair to this map.
- * @param kv the key/value pair
- * @return A new map with the new binding added to this map
+ /** Add a key/value pair to this map.
+ * @tparam B1 type of the value of the new binding, a supertype of `B`
+ * @param kv the key/value pair
+ * @return A new $coll with the new binding added to this map
*/
override def + [B1 >: B] (kv: (A, B1)): TreeMap[A, B1] = updated(kv._1, kv._2)
@@ -84,15 +97,22 @@ class TreeMap[A, +B](override val size: Int, t: RedBlack[A]#Tree[B])(implicit va
* either the collection itself (if it is mutable), or a new collection
* with the added elements.
*
+ * @tparam B1 type of the values of the new bindings, a supertype of `B`
* @param elem1 the first element to add.
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
+ * @return a new $coll with the updated bindings
*/
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): TreeMap[A, B1] =
this + elem1 + elem2 ++ elems
/** A new TreeMap with the entry added is returned,
* assuming that key is <em>not</em> in the TreeMap.
+ *
+ * @tparam B1 type of the values of the new bindings, a supertype of `B`
+ * @param key the key to be inserted
+ * @param value the value to be associated with `key`
+ * @return a new $coll with the inserted binding, if it wasn't present in the map
*/
def insert [B1 >: B](key: A, value: B1): TreeMap[A, B1] = {
assert(tree.lookup(key).isEmpty)
@@ -103,11 +123,11 @@ class TreeMap[A, +B](override val size: Int, t: RedBlack[A]#Tree[B])(implicit va
if (tree.lookup(key).isEmpty) this
else TreeMap.make(size - 1, tree.delete(key))
- /** Check if this map maps <code>key</code> to a value and return the
+ /** Check if this map maps `key` to a value and return the
* value if it exists.
*
* @param key the key of the mapping of interest
- * @return the value of the mapping, if it exists
+ * @return the value of the mapping, if it exists
*/
override def get(key: A): Option[B] = tree.lookup(key) match {
case n: NonEmpty[b] => Some(n.value)