实现时最好有什么Memento pattern (用于撤消/重做)
在女巫收藏中保留纪念品?
基本上,我需要这个(c = 更改,u = 撤销,r = 重做):
0
*c
-1 0
*c
-2 -1 0
*c
-3 -2 -1 0
<u
-2 -1 0 1
*c
-3 -2 -1 0
变体:
最佳答案
最后,我使用了 LinkedList
Public Sub Add(ByVal item As T)
If _list.Count > 0 Then
If Me.IsFull Then
' we forgot (delete) the oldest state '
_list.RemoveFirst()
End If
' remove all the following the current items objects '
Dim lastNode As LinkedListNode(Of T) = _list.Last
While Not Object.ReferenceEquals(_currentNode, lastNode)
_list.RemoveLast()
lastNode = _list.Last
End While
End If
' add the new item and point current to it '
_currentNode = _list.AddLast(item)
End Sub
关于.net - 使用 Memento : Stack, 队列或仅使用 LinkedList 撤消/重做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2333416/