treemap.scala.disabled
来自「JAVA 语言的函数式编程扩展」· DISABLED 代码 · 共 102 行
DISABLED
102 行
/* __ *\** ________ ___ / / ___ Scala API **** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: TreeMap.scala 8997 2006-10-19 20:52:30Z odersky $package scala.collection.immutableobject TreeMap { def Empty[A <% Ordered[A], B] = new TreeMap[A, B]}/** This class implements immutable maps using a tree. * * @author Erik Stenman * @author Matthias Zenger * @version 1.1, 03/05/2004 */[serializable]class TreeMap[A <% Ordered[A], B] extends Tree[A, Pair[A, B]] with Map[A, B] { override protected type This = TreeMap[A, B] override protected def getThis: This = this /** A factory to create empty maps of the same type of keys. */ def empty[C] = new TreeMap[A, C] /** Creates a new TreeMap from a GBTree and its size. * * @param sz ... * @param t ... * @return ... */ protected def New(sz: Int, t: aNode): This = new TreeMap[A, B] { override def size = sz override protected def tree: aNode = t } /** A new TreeMap with the entry added is returned, * if key is <em>not</em> in the TreeMap, otherwise * the key is updated with the new entry. * * @param key ... * @param value ... * @return ... */ def update [B1 >: B](key: A, value: B1) = updateOrAdd(key, {key, value}) /** A new TreeMap with the entry added is returned, * assuming that key is <em>not</em> in the TreeMap. */ def insert [B1 >: B](key:A, value:B) = add(key, {key, value}) /** Removes the key from the TreeMap. */ def remove(key:A) = deleteAny(key) /** Check if this map maps <code>key</code> 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 */ override def get(key: A): Option[B] = findValue(key) match { case Some(Pair(_, value)) => Some(value) case _ => None } /** 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. * * @param key the key * @return the value associated with the given key. * @throws Error("key not found"). */ override def apply(key: A): B = tree.apply(key)._2 /** Creates a list of all (key, value) mappings. * * @return the list of all mappings */ override def toList: List[Pair[A, B]] = tree.toList(scala.Nil) map (._2) /** Creates a new iterator over all elements contained in this * object. * * @return the new iterator */ def elements: Iterator[Pair[A, B]] = entries}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?