indexedstorage.scala

来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 49 行

SCALA
49
字号
/*                     __                                               *\**     ________ ___   / /  ___     Scala API                            ****    / __/ __// _ | / /  / _ |    (c) 2002-2007, LAMP/EPFL             ****  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **** /____/\___/_/ |_/____/_/ | |                                         ****                          |/                                          **\*                                                                      */// $Id: IndexedStorage.scala 14634 2008-04-12 00:56:51Z emir $package scala.xml.persistentimport scala.collection.mutableimport java.io.File/** indexed multiset of xml trees. The index may be an arbitrary totally * type, especially one can construct indices by selecting parts of * xml nodes. */class IndexedStorage[A](file:  File, index: Index[A]) //@todoextends CachedFileStorage(file) {  private var theMap: mutable.Map[A,Node] = new mutable.HashMap[A,Node]()  super.initialNodes.foreach { x:Node => this += x }  this.dirty = false  def += (e: Node): Unit = synchronized {     log("added element at index '"+index(e)+"'")    dirty = true    theMap(index(e)) = e  }    def -= (e: Node): Unit = synchronized {     log("removed element at index '"+index(e)+"'")    dirty = true    theMap -= index( e )  }    def nodes: Iterator[Node] = synchronized {     theMap.values  }  def lookup(n: A): Option[Node] = theMap.get(n)}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?