data structure used to implement UNDO and REDO option

前端 未结 5 801
天命终不由人
天命终不由人 2020-12-02 05:19

I want to implement UNDO and REDO option(as we see in MS word etc). Can you suggest me a data structure for it, and how can i implement it.?

5条回答
  •  伪装坚强ぢ
    2020-12-02 06:22

    Actually, the standard pattern for this functionality (Gang of Four, even) is Memento.

    Also, while most programs use Undo/Redo stacks, afficionados of certain text editors prefer Undo/Redo trees so that they don't lose their entire history if they undo a few commands, try a new one, and change their minds.

提交回复
热议问题