This commit is contained in:
krahets
2024-05-02 01:46:14 +08:00
parent a08cd961b3
commit 6d966b8b5d
30 changed files with 97 additions and 97 deletions
+4 -4
View File
@@ -28,8 +28,8 @@ A double-ended queue, which is a combination of a stack and a queue or two stack
**Q**: How exactly are undo and redo implemented?
Undo and redo operations are implemented using two stacks: Stack A for undo and Stack B for redo.
Undo and redo operations are implemented using two stacks: Stack `A` for undo and Stack `B` for redo.
1. Each time a user performs an operation, it is pushed onto Stack A, and Stack B is cleared.
2. When the user executes an "undo", the most recent operation is popped from Stack A and pushed onto Stack B.
3. When the user executes a "redo", the most recent operation is popped from Stack B and pushed back onto Stack A.
1. Each time a user performs an operation, it is pushed onto Stack `A`, and Stack `B` is cleared.
2. When the user executes an "undo", the most recent operation is popped from Stack `A` and pushed onto Stack `B`.
3. When the user executes a "redo", the most recent operation is popped from Stack `B` and pushed back onto Stack `A`.