保存状态:一类撤消是实际保存历史状态的地方。在这种情况下,会发生的情况是,在每个点上,您都会继续将状态保存在内存的某个位置。当您想要撤消时,只需交换当前状态并交换内存中已有的状态即可。例如,这就是通过 Adobe Photoshop 中的“历史记录”或在 Google Chrome 中重新打开关闭的选项卡来完成的。
GENERATE STATE:
The other category is where instead of maintaining the states themselves, you just remember what the actions were. when you need to undo, you need to do a logical reverse of that particular action. For a simple example, when you do a Ctrl+B in some text editor that supports undo's, it is remembered as a Bold action. Now with each action is a mapping of its logical reverses. So, when you do a Ctrl+Z, it looks up from a inverse actions table and finds that the undo action is a Ctrl+B again. That is performed and you get your previous state. So, here your previous state was not stored in memory but generated when you needed it.