Undo/Redo using Memento: Stack, Queue or just LinkedList?
- by serhio
What is the best having when implementing Memento pattern (for Undo/Redo)
in witch collection to Keep Mementos?
Basically, I need this(c = change, u = undo, r = redo):
0
*c
-1 0
*c
-2 -1 0
*c
-3 -2 -1 0
<u
-2 -1 0 1
*c
-3 -2 -1 0
Variants:
LinkedList - possible in principle, maybe not optimized.
Queue - not adapted for this task, IMO.
Stack - not adapted for undo AND redo;
Double Stack - maybe optimal, but can't control the undo maximum size.