blob: d094e6514a9d876b9ab4c31e27ab8e429b4a0c68 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package scala.xml.persistent
import scala.collection.mutable
import java.io.File
/** a persistent store with set semantics. This class allows to add and remove
* trees, but never contains two structurally equal trees.
*/
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 }
}
|