setstorage.scala
来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 44 行
SCALA
44 行
/* __ *\** ________ ___ / / ___ Scala API **** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **** /____/\___/_/ |_/____/_/ | | **** |/ **\* */// $Id: SetStorage.scala 14634 2008-04-12 00:56:51Z emir $package scala.xml.persistentimport scala.collection.mutableimport java.io.File/** A persistent store with set semantics. This class allows to add and remove * trees, but never contains two structurally equal trees. * * @author Burak Emir */class SetStorage(file: File) extends CachedFileStorage(file) { private var theSet: mutable.HashSet[Node] = new mutable.HashSet[Node] // initialize { val it = super.initialNodes dirty = it.hasNext for(val x <- it) { theSet += x; } } /* forwarding methods to hashset*/ def += (e: Node): Unit = synchronized { this.dirty = true; theSet += e } def -= (e: Node): Unit = synchronized { this.dirty = true; theSet -= e } def nodes = synchronized { theSet.elements }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?