diff options
Diffstat (limited to 'src/library/scala/collection/mutable/RevertableHistory.scala')
-rw-r--r-- | src/library/scala/collection/mutable/RevertableHistory.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/RevertableHistory.scala b/src/library/scala/collection/mutable/RevertableHistory.scala new file mode 100644 index 0000000000..c9bb1ef6d1 --- /dev/null +++ b/src/library/scala/collection/mutable/RevertableHistory.scala @@ -0,0 +1,31 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +** $Id$ +\* */ + +package scala.collection.mutable; + + +/** A revertable history is a <code>History</code> object which supports + * an undo operation. Type variable <code>A</code> refers to the type + * of the published events, <code>B</code> denotes the publisher type. + * Type <code>B</code> is typically a subtype of <code>Publisher</code>. + * + * @author Matthias Zenger + * @version 1.0, 08/07/2003 + */ +[serializable] +class RevertableHistory[A <: Undoable, B] extends History[A, B] with Undoable { + + /** Rollback the full history. + */ + def undo: Unit = { + val old = log.toList.reverse; + clear; + old.foreach { case Pair(sub, event) => event.undo; } + } +} |