summaryrefslogblamecommitdiff
path: root/src/library/scala/collection/mutable/RevertableHistory.scala
blob: c285d6c88818cfb1e65fcb74919806cf3ca2b3a9 (plain) (tree)
1
2
3
4
5
6
7
8

                                                                          
                                                                          


                                                                          

                                                                          


       
                                 

 






                                                                         
   
              
                                                                               
 

                                  
                      

                                     
                                                            

     
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2006, 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; }
    }
}